Crash because of a command :(
#1

Hello i got /ar and /rape

When i done /rape my server crashes when i do /ar i see the player afk and i see on my screen "Arrested"

But it suppose to do it for him. and /uncuff if player is not cuffed it says

You have uncuffed him
You can't uncuff someone that not cuffed.
PHP код:
CMD:rape(playerid,params[])
{
  if(
IsPlayerPolice[playerid] != 0) return SendClientMessage(playerid,-1,"{ff0000}Cops are not allowed to rape.");
  new 
targetidFloat:xFloat:yFloat:z;
  if(
sscanf(params"u"targetid)) return SendClientMessage(playerid, -1"USAGE: /rape [Part of name/Player ID]");
  if(
playerid == targetid) return SendClientMessage(playerid, -1"{FF0000}[ERROR]: You can't rape yourself");
  if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid0xFFFFFFF,"{ff0000}[ERROR]: This player is not connected!");
  if(!
IsPlayerSpawned[playerid]) return SendClientMessage(playeridCOLOR_RED"[ERROR]: You must be spawned to use that command");
  
GetPlayerPos(playerid,x,y,z);
  if(
IsPlayerInRangeOfPoint(targetid5.0x,y,z))
  {
    new 
str[512];
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridname,sizeof(name));
    new 
target[MAX_PLAYER_NAME];
    
GetPlayerName(targetidtarget,sizeof(target));
    
format(strsizeof(str), "{ff0000}You have raped %s",target);
    
SendClientMessage(playerid0xE01B1Bstr);
    
ApplyAnimation(playerid"MISC""BITCH_SLAP"0,0,0,0,0,0,0);
    }
  return 
1;
}
CMD:ar(playeridparams[]) return cmd_arrest(playeridparams);
CMD:arrest(playerid,params[])
{
 new 
targetidstr[512];
 if(
IsPlayerPolice[playerid] != 1) return SendClientMessage(playerid,-1,"{ff0000}[ERROR]: You are not cop.");
 if(
sscanf(params"u"targetid)) return SendClientMessage(playerid, -1,"USAGE: /arrest [Part of Name/Player ID]");
 if(
playerid == targetid) return SendClientMessage(playerid0xFFFFFFF"{ff0000}ERROR: You can't arrest yourself");
 if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid0xFFFFFFF,"{FF0000}ERROR: This player is not connected!");
 if(
IsPlayerPolice[targetid] == 1) return SendClientMessage(playerid, -2"{ff0000}You cant arrest another police officer!");
 if(!
SetPlayerAttachedObject(targetid0194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977,-81.7000350.8919991.0000001.168000)) return SendClientMessage(playerid,-1,"[ERROR] This player is not cuffed!");
 new 
name [MAX_PLAYER_NAME];
 
GetPlayerName(playeridname,sizeof(name));
 new 
target[MAX_PLAYER_NAME];
 
GetPlayerName(targetidtargetsizeof(target));
 
format(strsizeof(str), "{ff0000}You have arrested %s",target);
 
SendClientMessage(playerid0xE01B1Bstr);
 
GameTextForPlayer(playerid"ARRESTED",2000,2);
 
SendClientMessageToAll(-1"{ff0000}%s Has been sent to jail");
 
SetPlayerInterior(playerid6);
 
ResetPlayerWeapons(playerid);
 return 
1;
}
CMD:site(playeridparams[])
{
  
SendClientMessage(playerid, -1"{FF9966}[BOT]{FFFFFF}: Our website is {FF0000}www.lscnr-samp.url.ph");
  return 
1;
}
CMD:uncuff(playeridparams[])
{
 new 
targetid;
 if(
IsPlayerPolice[playerid] != 1) return SendClientMessage(playerid, -1"{ff0000}[ERROR]: You are not a cop.");
 if(
sscanf(params"u"targetid)) return SendClientMessage(playerid,-1"USAGE: /uncuff [Part of name/Player Id]");
 if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid0xFFFFFFF"{ff0000}ERROR This Player Is Not Connected!");
 if(
playerid == targetid) return SendClientMessage(playerid0xFF0000FF"ERROR You are a police officer, You cannot be cuffed.!");
 new 
Float:xFloat:yFloat:z;
 
GetPlayerPos(playeridx,y,z);
 if(
IsPlayerInRangeOfPoint(targetid5.0xyz))
 {
   if(!
SetPlayerAttachedObject(targetid0194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977,-81.7000350.8919991.0000001.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");
   new 
str[512];
   new 
name [MAX_PLAYER_NAME];
   
GetPlayerName(playeridname,sizeof(name));
   new 
target[MAX_PLAYER_NAME];
   
GetPlayerName(targetidname,sizeof(target));
   
format(strsizeof(str), "{00FF00}You Have Uncuffed {ff0000}%s",target);
   
SendClientMessage(playerid0xE01B1Bstr);
   
format(strsizeof(str), "{ff0000}You Have Been Uncuffed!",name);
   
SendClientMessage(playerid0xE01B1Bstr);
   return 
1;
 }
 return 
1;

Reply
#2

the cmd "arrest" look this line:
pawn Код:
GameTextForPlayer(playerid, "ARRESTED",2000,2);
you replaced targetid with playerid, add targetid instead.

and , for the rape command crash, "BITCH_SLAP" is not a valid animation, replace it with "bitchslap"

Код:
 An invalid animation library will crash the player's game.
From SA:MP wiki
Reply
#3

Okay ty but what about uncuff? you know why ?
Reply
#4

Not sure about this but you may add a variable for "CreateObject" (the object which attached to player) and check if it's attached to him and if the object is INVALID_OBJECT_ID or not.
Reply
#5

Make a global variable
new Cuffed[MAX_PLAYERS];

Under Onplayerconnect, Cuffed[playerid]=0;

Inside the cuff command, Cuffed[playerid]=1;

Inside uncuff add, if(!Cuffed[playerid]) return SendClientMessage(playerid,......
And after uncuffing, do
Cuffed[playerid]=0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)