A Command!
#1

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(playeridparams[])
{
     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(targetid3);
            
SetPlayerColor(targetidYELLOW);
            
GameTextForPlayer(targetid"~Y~ESCAPED FROM ~G~ARRESTED ~P~ RUN BABY!!!"70005);
            
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;

Reply
#2

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
Reply
#3

I suggest that do not check them based on skins.
Reply
#4

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.
Reply
#5

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] == && Civilian(GetPlayerSkin(playerid))) 
Reply
#6

anyone
Reply
#7

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
Reply
#8

Gets told the skin checking is a bad idea... Posts up more threads still using it and ignores anyone saying that it's bad...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)