A Command! - 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)
+--- Thread: A Command! (
/showthread.php?tid=653381)
A Command! -
Thanks - 02.05.2018
I've creating a command for break the cuffs! And I've do it only for Civilian BUT If someone go Cops he can use it too!! Why?
PHP Code:
CMD:breakcuff(playerid, params[])
{
if(!Civilian(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1, "{ff0000}Error: {Ffffff}Only Civilian can use this comamnd");
{
new targetid;
if(BeginArrested[targetid] == 1)
{
KillTimer(BeginArrestedTime[targetid]);
SendClientMessage(targetid, -1, "{FF7000}YOU HAVE BEEN ESCAPED FROM ARRESTED!!! RUN RUN !!!!");
SetPlayerWantedLevel(targetid, 3);
SetPlayerColor(targetid, YELLOW);
GameTextForPlayer(targetid, "~Y~ESCAPED FROM ~G~ARRESTED ~P~ RUN BABY!!!", 7000, 5);
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);
BeginArrested[targetid] = 0;
}
else SendClientMessage(targetid, -1, "{FF0000}Error: {FFFFFF}You can use this command only while be cuffed or arrested.");
}
return 1;
}
PHP Code:
stock PoliceTeam(skinid)
{
switch(skinid)
{
case 280:return 1;
case 285:return 1;
case 165:return 1;
case 166:return 1;
case 286:return 1;
case 287:return 1;
default: return 0;
}
return 0;
}
stock Civilian(skinid)
{
switch(skinid)
{
case 1..300:return 1;
default: return 0;
}
return 0;
}
Re: A Command! -
XWolfX - 02.05.2018
Im not quite sure but i think your Civilian skins id overlap PoliceTeam skins so i think u should do this kind of checking is a player skin id
Code:
CMD:breakcuff(playerid, params[])
{
if(PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1, "{ff0000}Error: {Ffffff}Only Civilian can use this comamnd");
{
new targetid;
else if(BeginArrested[targetid] == 1 && Civilian(GetPlayerSkin(playerid)))
{
KillTimer(BeginArrestedTime[targetid]);
SendClientMessage(targetid, -1, "{FF7000}YOU HAVE BEEN ESCAPED FROM ARRESTED!!! RUN RUN !!!!");
SetPlayerWantedLevel(targetid, 3);
SetPlayerColor(targetid, YELLOW);
GameTextForPlayer(targetid, "~Y~ESCAPED FROM ~G~ARRESTED ~P~ RUN BABY!!!", 7000, 5);
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);
BeginArrested[targetid] = 0;
}
else SendClientMessage(targetid, -1, "{FF0000}Error: {FFFFFF}You can use this command only while be cuffed or arrested.");
}
return 1;
}
Im sorry if i was not helpfull but im new at scripting

EDIT: I bolded stuff that i have changed
Re: A Command! -
Fairuz - 02.05.2018
I suggest that do not check them based on skins.
Re: A Command! -
Sew_Sumi - 02.05.2018
Personally I'd use an enum or an array to define who is in what, then they don't need to be in a certain skin to be recognized by the script.
Re: A Command! -
Thanks - 03.05.2018
Hello I've got a 2erros of your code!!
Code:
error 001: expected token: ";", but found "if"
error 029: invalid expression, assumed zero
PHP Code:
else if(BeginArrested[targetid] == 1 && Civilian(GetPlayerSkin(playerid)))
Re: A Command! -
Thanks - 03.05.2018
anyone
Re: A Command! -
kovac - 03.05.2018
As I already told you before, the way you're checking for player team is VERY BAD. You should do what i told you here:
https://sampforum.blast.hk/showthread.php?tid=653111
Re: A Command! -
Sew_Sumi - 04.05.2018
Gets told the skin checking is a bad idea... Posts up more threads still using it and ignores anyone saying that it's bad...