Author Topic: RPG Commands  (Read 8304 times)

0 Members and 1 Guest are viewing this topic.

Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
RPG Commands
« on: September 03, 2011, 01:13:04 pm »
I am making a taze command but when I tried the timer it didnt work. For instance, I had }
   else if (strcmp(cmd, "taze", true) == 0) {
      new szMsg[256], plr;
      tmp = strtok(cmdtext, idx), plr = FindPlayerIDFromString(tmp);
      if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
      else if (!strlen(tmp)) SendClientMessage(playerid,COLOR_RED,"USAGE: /c taze [Nick/ID]");
        else if (PlayerInfo[playerid][cop] != 1) SendClientMessage(playerid, COLOR_ORANGE, "Only officers can taze suspects.");
        else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Unknown player");
      else {
         format(szMsg,sizeof(szMsg),"Officer %s tazed suspect %s for 5 seconds",gPlayers[playerid],gPlayers[plr]);
            SetTimer("taze",5000,1);
         SendClientMessageToAll(COLOR_YELLOW,szMsg);
            TogglePlayerControllable(plr,0);
      }
      return 1;

I followed yazeens post in fuzzys topic, so I had this,

stock taze()
{
TogglePlayerControllable(playerid,0);
}

but when I taze myself I keep being frozen and it wont unfreeze me after 5 seconds

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: RPG Commands
« Reply #1 on: September 03, 2011, 10:36:19 pm »
Look at taze() really carefully.
Code: [Select]
stock taze()
{
TogglePlayerControllable(playerid,0);
}

Where is it getting playerid from? It can't get it from the command itself.
Do not PM me for support.




Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: RPG Commands
« Reply #2 on: September 03, 2011, 11:34:53 pm »
oh ok, so where it say 'SetTimer' i have to add the playerid at the end? just like i would if I wanted to make a heal command it would be gplayer? So like SetTimer("taze",5000,1), gPlayers[playerid]); ?
I get two errors from it though
« Last Edit: September 03, 2011, 11:44:49 pm by kitt85711 »

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: RPG Commands
« Reply #3 on: September 04, 2011, 01:26:22 am »
You can't pass parameters to a timer. You're going to have to make another implementation.
Do not PM me for support.




Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: RPG Commands
« Reply #4 on: September 04, 2011, 02:39:14 am »
Like this?

stock taze( playerid, cmd[] )
{
TogglePlayerControllable(playerid,0);
}

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: RPG Commands
« Reply #5 on: September 04, 2011, 12:18:41 pm »
There's still no way for the function to know where playerid is coming from.
Do not PM me for support.




Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: RPG Commands
« Reply #6 on: September 04, 2011, 12:44:19 pm »
LOL. [pawn]   else if (strcmp(cmd, "taze", true) == 0) {
      new szMsg[256], plr;
      tmp = strtok(cmdtext, idx), plr = FindPlayerIDFromString(tmp);
      if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
      else if (!strlen(tmp)) SendClientMessage(playerid,COLOR_RED,"USAGE: /c taze [Nick/ID]");
        else if (PlayerInfo[playerid][cop] != 1) SendClientMessage(playerid, COLOR_ORANGE, "Only officers can taze suspects.");
        else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Unknown player");
      else {
         format(szMsg,sizeof(szMsg),"Officer %s tazed suspect %s for 5 seconds",gPlayers[playerid],gPlayers[plr]);
            SetTimer("taze",5000,1);
            SendClientMessageToAll(COLOR_YELLOW,szMsg);
            TogglePlayerControllable(plr,0);
      }
      return 1;[/pawn]

If your script is like this, than your script should be something like this:

Put this at the bottom of your script.
[pawn]public taze(playerid)
{
   TogglePlayerControllable(playerid,1);
   return 1;
}[/pawn]

Then forward your script.
forward taze

This Script Isn't Tested!
I'm beginning to feel like a Lag God, Lag God

Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: RPG Commands
« Reply #7 on: September 04, 2011, 02:19:04 pm »
lol >.< so simple... Big H or one of you can now say fail or something, like u always have :P

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: RPG Commands
« Reply #8 on: September 04, 2011, 02:43:24 pm »
forward taze(playerid);

I did a mistake.  :-X
I'm beginning to feel like a Lag God, Lag God

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: RPG Commands
« Reply #9 on: September 05, 2011, 12:27:47 am »
I don't think you guys understand that the taze function won't be able to take parameters through a timer, and it will still be bugged. By default, it'll go with ID 0.
Do not PM me for support.




Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: RPG Commands
« Reply #10 on: September 05, 2011, 03:42:46 am »
I didn't really add the forward and it works fine i think, it freezes me for 5 seconds but i had to change '1' to '0' because it was spamming 'controls have been restored' I left out the forward but what do you mean stormeous? what bug does it make?

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: RPG Commands
« Reply #11 on: September 05, 2011, 04:38:33 am »
I don't really know much about timers.
I'm beginning to feel like a Lag God, Lag God

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: RPG Commands
« Reply #12 on: September 05, 2011, 07:04:14 am »
Change your command script to this:
[pawn]   else if (strcmp(cmd, "taze", true) == 0) {
      new szMsg[256], plr;
      tmp = strtok(cmdtext, idx), plr = FindPlayerIDFromString(tmp);
      if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
      else if (!strlen(tmp)) SendClientMessage(playerid,COLOR_RED,"USAGE: /c taze [Nick/ID]");
        else if (PlayerInfo[playerid][cop] != 1) SendClientMessage(playerid, COLOR_ORANGE, "Only officers can taze suspects.");
        else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Unknown player");
      else {
         format(szMsg,sizeof(szMsg),"Officer %s tazed suspect %s for 5 seconds",gPlayers[playerid],gPlayers[plr]);
            SetTimer("taze",5000,0);
            SendClientMessageToAll(COLOR_YELLOW,szMsg);
            TogglePlayerControllable(plr,0);
      }
      return 1;[/pawn]

Add this to the bottom:
[pawn]public taze(playerid)
{
   TogglePlayerControllable(playerid,1);
   return 1;
}[/pawn]

And then put this at the top of your script.
Code: [Select]
forward taze(playerid);
;) I think why you get Spam messages is because SetTimer("taze",5000,1);. All you have to do is change it to 0 so that it won't repeat again.
I'm beginning to feel like a Lag God, Lag God

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: RPG Commands
« Reply #13 on: September 05, 2011, 10:47:00 am »
Again, guys, the function won't work the way you want to. Here's your timer
[pawn]
SetTimer("taze",5000,1);
[/pawn]

You tell it to call the function "taze" in 5 seconds. That's all you tell it to do. Whereas your taze function:
[pawn]
public taze(playerid)
{
   TogglePlayerControllable(playerid,1);
   return 1;
}
[/pawn]

Needs a playerid. You can't assume the playerid gets passed from the command. That's not how it works. You need to specifically give it the player ID.

Since Pawn's timers do not allow you to pass parameters, there is no way to make a tazer the way this is scripted.
Do not PM me for support.




Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: RPG Commands
« Reply #14 on: September 05, 2011, 02:19:17 pm »
Stormeous I found out now. It was giving bugs to my server even if i didnt have errors, so like i tazed someone then it freezes someone but the thing is it wont unfreeze them it shows 'Controls have been revoked' on their screen then on my screen it shows 'Controls have been restored'

And what your saying I can never make a taze command in vcmp? or panwo, or the way I'm making it?

And you were right I tried to make a god mode but the thing is it was only working for my friend and not me and his id was 0

Stormeus I would really appreciate it if you could like show me how to make it right because after that god mode bug i was trying a bunch of crap to fix it but didnt work. For instance I tried,

public taze(playerid,plr)
{
   TogglePlayerControllable(playerid,1);
   return 1;
}

public taze(gPlayers[plr])
{
   TogglePlayerControllable(playerid,1);
   return 1;
}

public taze(plr)
{
   TogglePlayerControllable(plr,1);
   return 1;
}


public taze(plr)
{
   TogglePlayerControllable(gPlayers[plr],1);
   return 1;
}


A bunch of crap like that...

Can you like show me because I'm having a hard time understanding what your saying