Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: kitt85711 on September 03, 2011, 01:13:04 pm

Title: RPG Commands
Post by: kitt85711 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
Title: Re: RPG Commands
Post by: stormeus 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.
Title: Re: RPG Commands
Post by: kitt85711 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
Title: Re: RPG Commands
Post by: stormeus 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.
Title: Re: RPG Commands
Post by: kitt85711 on September 04, 2011, 02:39:14 am
Like this?

stock taze( playerid, cmd[] )
{
TogglePlayerControllable(playerid,0);
}
Title: Re: RPG Commands
Post by: stormeus on September 04, 2011, 12:18:41 pm
There's still no way for the function to know where playerid is coming from.
Title: Re: RPG Commands
Post by: Fuzzy168 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!
Title: Re: RPG Commands
Post by: kitt85711 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
Title: Re: RPG Commands
Post by: Fuzzy168 on September 04, 2011, 02:43:24 pm
forward taze(playerid);

I did a mistake.  :-X
Title: Re: RPG Commands
Post by: stormeus 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.
Title: Re: RPG Commands
Post by: kitt85711 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?
Title: Re: RPG Commands
Post by: Fuzzy168 on September 05, 2011, 04:38:33 am
I don't really know much about timers.
Title: Re: RPG Commands
Post by: Fuzzy168 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.
Title: Re: RPG Commands
Post by: stormeus 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.
Title: Re: RPG Commands
Post by: kitt85711 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
Title: Re: RPG Commands
Post by: kitt85711 on September 05, 2011, 02:21:49 pm
omg, after I red what you said carfuly I think its suposed to be like SetTimer("taze",5000,plr); ???
Title: Re: RPG Commands
Post by: stormeus on September 05, 2011, 02:48:50 pm
It SHOULD be something like
SetTimer("taze",5000,1,playerid);

This is invalid. It will not work. This entire functionality will not work in Pawn until timers are allowed to pass parameters. Or you could rescript everything in Squirrel... (http://vcmp.liberty-unleashed.co.uk)
Title: Re: RPG Commands
Post by: yazeen on September 05, 2011, 02:53:13 pm
Oh i failed @ there kittrell i forgot to add some stuffs and about your script use array something like (Note:just an example)

on top of your script:

[pawn]new jailed[256];
[/pawn]

on bottom:
[pawn]stock taze()
{
playerid = //Function >> GetPlayerIDFromName(jailed); //<<EXAMPLE
ToggleplayerControl(playerid,1);
}[/pawn]

Timer:

SetTimer("taze",5000,0);

Player will be unfreezed after 5 seconds. This is just an example and you need to edit it alot!
(I am not at my computer and i just downloaded shadow's shit and pasted it so credits to shadow)
Title: Re: RPG Commands
Post by: stormeus on September 05, 2011, 02:55:34 pm
That would need a lot of editing. Also, if coincidentally, two players got tazed within five seconds of each other, one would be unfrozen while the other would be stuck.
Title: Re: RPG Commands
Post by: kitt85711 on September 06, 2011, 01:11:43 am
But thats the thing... There was only two people on my server, me and my friend. And when I tazed him he would be frozen, I can still move and after 5 seconds hes still frozen and I get the 'controls have been restored' when I was already moving and major bug...
Title: Re: RPG Commands
Post by: heekz.shadow on September 14, 2011, 09:04:38 am
DAARN! I hate that Stormeus know from Argonath script and all that but he won't share!!!

UP :
Code: [Select]
new IsTazed[MAX_PLAYERS];
COMMAND (at TogglePlayerControllable(plr,0) :
Code: [Select]
IsTazed[plr] = 1;
THE TIMER:
Code: [Select]
public shit() {
new i=0;
for( i < 50; i++ ) {
if(IsPlayerConnected(i))
{
if(IsTazed[i] == 1)
{
TogglePlayerControllable(i,1);
IsTazed[i] = 0;
}
}
}
return 1;
}


TAKE damn care. its just SetTimer("shit",5000,0);
Title: Re: RPG Commands
Post by: Force on September 14, 2011, 07:33:05 pm
Wow.. you people are getting worse and worse with your scripts, they are so bad. Ditch PAWN and move onto something that actually works properly and isn't a steaming pile of shit.

</rant>
Title: Re: RPG Commands
Post by: stormeus on September 17, 2011, 06:26:47 pm
DAARN! I hate that Stormeus know from Argonath script and all that but he won't share!!!
I won't share them because: