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 
targetid, Float:x, Float:y, Float: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(playerid, 0xFFFFFFF,"{ff0000}[ERROR]: This player is not connected!");
  if(!
IsPlayerSpawned[playerid]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You must be spawned to use that command");
  
GetPlayerPos(playerid,x,y,z);
  if(
IsPlayerInRangeOfPoint(targetid, 5.0, x,y,z))
  {
    new 
str[512];
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, name,sizeof(name));
    new 
target[MAX_PLAYER_NAME];
    
GetPlayerName(targetid, target,sizeof(target));
    
format(str, sizeof(str), "{ff0000}You have raped %s",target);
    
SendClientMessage(playerid, 0xE01B1B, str);
    
ApplyAnimation(playerid, "MISC", "BITCH_SLAP", 0,0,0,0,0,0,0);
    }
  return 
1;
}
CMD:ar(playerid, params[]) return cmd_arrest(playerid, params);
CMD:arrest(playerid,params[])
{
 new 
targetid, str[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(playerid, 0xFFFFFFF, "{ff0000}ERROR: You can't arrest yourself");
 if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFFFF,"{FF0000}ERROR: This player is not connected!");
 if(
IsPlayerPolice[targetid] == 1) return SendClientMessage(playerid, -2, "{ff0000}You cant arrest another police officer!");
 if(!
SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000)) return SendClientMessage(playerid,-1,"[ERROR] This player is not cuffed!");
 new 
name [MAX_PLAYER_NAME];
 
GetPlayerName(playerid, name,sizeof(name));
 new 
target[MAX_PLAYER_NAME];
 
GetPlayerName(targetid, target, sizeof(target));
 
format(str, sizeof(str), "{ff0000}You have arrested %s",target);
 
SendClientMessage(playerid, 0xE01B1B, str);
 
GameTextForPlayer(playerid, "ARRESTED",2000,2);
 
SendClientMessageToAll(-1, "{ff0000}%s Has been sent to jail");
 
SetPlayerInterior(playerid, 6);
 
ResetPlayerWeapons(playerid);
 return 
1;
}
CMD:site(playerid, params[])
{
  
SendClientMessage(playerid, -1, "{FF9966}[BOT]{FFFFFF}: Our website is {FF0000}www.lscnr-samp.url.ph");
  return 
1;
}
CMD:uncuff(playerid, params[])
{
 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(playerid, 0xFFFFFFF, "{ff0000}ERROR This Player Is Not Connected!");
 if(
playerid == targetid) return SendClientMessage(playerid, 0xFF0000FF, "ERROR You are a police officer, You cannot be cuffed.!");
 new 
Float:x, Float:y, Float:z;
 
GetPlayerPos(playerid, x,y,z);
 if(
IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
 {
   if(!
SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");
   new 
str[512];
   new 
name [MAX_PLAYER_NAME];
   
GetPlayerName(playerid, name,sizeof(name));
   new 
target[MAX_PLAYER_NAME];
   
GetPlayerName(targetid, name,sizeof(target));
   
format(str, sizeof(str), "{00FF00}You Have Uncuffed {ff0000}%s",target);
   
SendClientMessage(playerid, 0xE01B1B, str);
   
format(str, sizeof(str), "{ff0000}You Have Been Uncuffed!",name);
   
SendClientMessage(playerid, 0xE01B1B, str);
   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)