Array must be indexed /cuff cmd
#1

pawn Код:
if(!strcmp(cmd,"/cuff",true))
    {
    giveplayername=ReturnUser(tmp); // this line
    cmd=strtok(cmdtext,idx);
    if(gTeam[playerid] == TEAM_POLICE)
    {
    if(!strlen(cmd)) return SendClientMessage(playerid,GREY,"USAGE: /cuff [playerid]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,"ERROR: Invalid player id!");
    TogglePlayerControllable(id,0);
    GameTextForPlayer(id, "~y~ Cuffed!",2500,3);
  new str[128];
  GetPlayerName(playerid, str, sizeof(str));
  GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
  format(str, sizeof(str), " * %s takes out his cuffs and places it on %s hands. ", str, giveplayername);
  ProxDetector(50.0, playerid, str,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA);
  return 1;
    }
    else
    {
    SendClientMessage(playerid, RED, "ERROR: You're not a police officer!");
    }
    return true;
    }
And I have the "new Giveplayername[MAX_PLAYER_NAME];" at top of the OnPlayerCommandText..

Thank you.

And yes, I have searched.
Reply
#2

it should probably be giveplayerid
Reply
#3

Quote:
Originally Posted by Μαστερμινδ
it should probably be giveplayerid
EDIT: Isnt working :/
Reply
#4

Quote:
Originally Posted by [eX
Klutty ]
EDIT: Isnt working :/
What do you mean not working? What errors you get?
Reply
#5

Quote:
Originally Posted by MadeMan
Quote:
Originally Posted by [eX
Klutty ]
EDIT: Isnt working :/
What do you mean not working? What errors you get?
When Im ingame it says "* Klutty takes out his cuffs and places it on я hands."
Reply
#6

pawn Код:
if(!strcmp(cmd,"/cuff",true))
{
new giveplayername[MAX_PLAYER_NAME];
cmd=strtok(cmdtext,idx);
GetPlayerName(idx, giveplayername, sizeof(giveplayername));
if(gTeam[playerid] == TEAM_POLICE)
{
if(!strlen(cmd)) return SendClientMessage(playerid,GREY,"USAGE: /cuff [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,"ERROR: Invalid player id!");
TogglePlayerControllable(id,0);
GameTextForPlayer(id, "~y~ Cuffed!",2500,3);
new str[128];
GetPlayerName(playerid, str, sizeof(str));
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
format(str, sizeof(str), " * %s takes out his cuffs and places it on %s hands. ", str, giveplayername);
ProxDetector(50.0, playerid, str,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA);
return 1;
}
else
{
SendClientMessage(playerid, RED, "ERROR: You're not a police officer!");
}
return true;
}
Reply
#7

Quote:
Originally Posted by еddy
pawn Код:
if(!strcmp(cmd,"/cuff",true))
{
new giveplayername[MAX_PLAYER_NAME];
cmd=strtok(cmdtext,idx);
GetPlayerName(idx, giveplayername, sizeof(giveplayername));
if(gTeam[playerid] == TEAM_POLICE)
{
if(!strlen(cmd)) return SendClientMessage(playerid,GREY,"USAGE: /cuff [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,"ERROR: Invalid player id!");
TogglePlayerControllable(id,0);
GameTextForPlayer(id, "~y~ Cuffed!",2500,3);
new str[128];
GetPlayerName(playerid, str, sizeof(str));
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
format(str, sizeof(str), " * %s takes out his cuffs and places it on %s hands. ", str, giveplayername);
ProxDetector(50.0, playerid, str,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA);
return 1;
}
else
{
SendClientMessage(playerid, RED, "ERROR: You're not a police officer!");
}
return true;
}
Without the new array it compiles without errors (i have that already at the start of onlayercmdtext)

Thanks.

EDIT: Now In game when I do /cuff 0 (my id) the victim name becomes my friends one (Qwerty) and he gets cuffed though I used MY id. :O
Reply
#8

Try this:

pawn Код:
if(!strcmp(cmd,"/cuff",true))
{
cmd=strtok(cmdtext,idx);
giveplayerid=ReturnUser(cmd);
if(gTeam[playerid] == TEAM_POLICE)
{
if(!strlen(cmd)) return SendClientMessage(playerid,GREY,"USAGE: /cuff [playerid]");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,RED,"ERROR: Invalid player id!");
TogglePlayerControllable(giveplayerid,0);
GameTextForPlayer(giveplayerid, "~y~ Cuffed!",2500,3);
new str[128];
GetPlayerName(playerid, str, sizeof(str));
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
format(str, sizeof(str), " * %s takes out his cuffs and places it on %s hands. ", str, giveplayername);
ProxDetector(50.0, playerid, str,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA);
return 1;
}
else
{
SendClientMessage(playerid, RED, "ERROR: You're not a police officer!");
}
return true;
}
Reply
#9

Go on the Wiki and have a read of the arrays section or the pdf or ****** (C type arrays).
Reply
#10

Quote:
Originally Posted by MadeMan
Try this:

pawn Код:
if(!strcmp(cmd,"/cuff",true))
{
cmd=strtok(cmdtext,idx);
giveplayerid=ReturnUser(cmd);
if(gTeam[playerid] == TEAM_POLICE)
{
if(!strlen(cmd)) return SendClientMessage(playerid,GREY,"USAGE: /cuff [playerid]");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,RED,"ERROR: Invalid player id!");
TogglePlayerControllable(giveplayerid,0);
GameTextForPlayer(giveplayerid, "~y~ Cuffed!",2500,3);
new str[128];
GetPlayerName(playerid, str, sizeof(str));
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
format(str, sizeof(str), " * %s takes out his cuffs and places it on %s hands. ", str, giveplayername);
ProxDetector(50.0, playerid, str,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA,0x6699FFAA);
return 1;
}
else
{
SendClientMessage(playerid, RED, "ERROR: You're not a police officer!");
}
return true;
}
Woo! It works! Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)