SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/05/2018, 10:43 PM   #1
Thanks
Huge Clucker
 
Join Date: Nov 2016
Posts: 284
Reputation: 0
Default A Command!

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;

Thanks is offline   Reply With Quote
Old 02/05/2018, 11:03 PM   #2
XWolfX
Little Clucker
 
Join Date: Nov 2012
Posts: 2
Reputation: 0
Default Re: A Command!

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

Last edited by XWolfX; 02/05/2018 at 11:35 PM.
XWolfX is offline   Reply With Quote
Old 03/05/2018, 12:23 AM   #3
Dice_
Huge Clucker
 
Dice_'s Avatar
 
Join Date: Sep 2015
Location: Indonesia
Posts: 450
Reputation: 57
Default Re: A Command!

I suggest that do not check them based on skins.
Dice_ is offline   Reply With Quote
Old 03/05/2018, 12:31 AM   #4
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,268
Reputation: 525
Default Re: A Command!

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.
Sew_Sumi is offline   Reply With Quote
Old 03/05/2018, 01:44 AM   #5
Thanks
Huge Clucker
 
Join Date: Nov 2016
Posts: 284
Reputation: 0
Default Re: A Command!

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))) 
Thanks is offline   Reply With Quote
Old 03/05/2018, 06:07 PM   #6
Thanks
Huge Clucker
 
Join Date: Nov 2016
Posts: 284
Reputation: 0
Default Re: A Command!

anyone
Thanks is offline   Reply With Quote
Old 03/05/2018, 06:17 PM   #7
kovac
Banned
 
Join Date: Mar 2018
Posts: 178
Reputation: 14
Default Re: A Command!

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: http://forum.sa-mp.com/showthread.php?t=653111
kovac is offline   Reply With Quote
Old 04/05/2018, 01:00 AM   #8
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,268
Reputation: 525
Default Re: A Command!

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 1 20/04/2018 01:12 PM
[Plugin] mcmd Command Engine - Plugin based command processing Mellnik Plugin Development 108 08/05/2016 02:55 PM
i had this command in my gamemode, when i type this in game,it tells server unknow command? Chrisli520 Scripting Help 3 24/11/2013 11:02 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 04:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 06:19 AM


All times are GMT. The time now is 04:46 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.