Cuff/Uncuff - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Cuff/Uncuff (
/showthread.php?tid=160415)
Cuff/Uncuff -
striker25 - 16.07.2010
I seem to have been failing to make a cuff and uncuff cmd always plenty of errors please help me D: my gteams are
if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
Re: Cuff/Uncuff -
KennethRandall - 16.07.2010
pawn Code:
if(gTeam[playerid] != COP || gTeam[playerid] != SWAT || gTeam[playerid] != ARMY || gTeam[playerid] != FBI) return SendClientMessage(playerid, COLOR_[yourcolor], "Your not allowed to cuff");
if(gTeam[playerid] == COP || gTeam[playerid] == SWAT || gTeam[playerid] == ARMY || gTeam[playerid] == FBI) {
// command effect
return 1;
}
Re: Cuff/Uncuff -
striker25 - 16.07.2010
i managed to make this but whenever i try to cuff a player i get cuffed myself
pawn Code:
if(!strcmp(cmd,"/cuff",true))
{
cmd=strtok(cmdtext,idx);
if(!strlen(cmd)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /cuff playerid");
TogglePlayerControllable(playerid,0);
GameTextForPlayer(playerid, "~y~ hand cuffs!",2500,3);
return true;
}
Re: Cuff/Uncuff -
[NTX]MikeQ - 16.07.2010
Its not that easy making a cmd with exxample: /ban [ID]
Re: Cuff/Uncuff -
striker25 - 16.07.2010
um any ideas how to fix that cmd?
Re: Cuff/Uncuff -
Hamza' - 16.07.2010
pawn Code:
if(!strcmp(cmdtext,"/cuff",true))
{
if(gTeam[playerid] = COP || gTeam[playerid] = SWAT || gTeam[playerid] = ARMY || gTeam[playerid] = FBI)
{
new giveplayerid;
tmp=strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /cuff playerid");
giveplayerid = ReturnUser(tmp);
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,COLOR_GREY,"Invalid player id.");
TogglePlayerControllable(giveplayerid,0);
GameTextForPlayer(giveplayerid, "~y~ You have been Cuffed!",2500,3);
}
return 1;
}
and Paste this on top
pawn Code:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21) // Strip out leading spaces
{
if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos])) // Check whole passed string
{
// If they have a numeric name you have a problem (although names are checked on id failure)
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
{
/*if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "User not connected");
}*/
userid = INVALID_PLAYER_ID;
}
else
{
return userid; // A player was found
}
}
/*else
{
if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
}
userid = INVALID_PLAYER_ID;
}
return userid;*/
// Removed for fallthrough code
}
Re: Cuff/Uncuff -
[XST]O_x - 16.07.2010
I'd suggest you moving to dcmd to make commands with parameters.
But if you insist:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp("/cuff", cmd, true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /cuff [playerid]");
if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,0xFF0000FF,"Player is not connected");
TogglePlayerControllable(strval(tmp),0);
GameTextForPlayer(strval(tmp), "~y~ hand cuffs!",2500,3);
return 1;
}
return 0;
}
Re: Cuff/Uncuff -
striker25 - 16.07.2010
thank you so much it works now and for fast response
Re: Cuff/Uncuff -
Hamza' - 16.07.2010
Welcome
Re: Cuff/Uncuff -
Hamza' - 16.07.2010
pawn Code:
if(strcmp("/uncuff", cmd, true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /uncuff [playerid]");
if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,0xFF0000FF,"Player is not connected");
TogglePlayerControllable(strval(tmp),1);
GameTextForPlayer(strval(tmp), "~y~ hands uncuffed!",2500,3);
return 1;
}