11.07.2018, 00:44
Use sscanf to assign targetid to whatever the user is typing in. Make sure you understand this, also you have a grammar issue in the script in your timer but I haven't changed it.
PHP код:
CMD:breakcuff(playerid, params[])
{
if(PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1, "{FF0000}[NayaBOT]: {FFFFFF}You cannot use this command.");
{
new pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[170], ArrestReward = random(15000) + 2500;
if (sscanf(params, "u", targetid))
return SendClientMessage(playerid, -1, "{FF0000}[NayaBOT]: {FFFFFF}/breakcuffs [playerid/name]");
if (targetid == INVALID_PLAYER_ID || !IsPlayerNearPlayer(playerid, targetid, 6.0))
return SendClientMessage(playerid, -1, "{FF0000}[NayaBOT]: {FFFFFF}The specified player is disconnected or not near you.");
if(TryingArrested[targetid] == 1 && Civilian(GetPlayerSkin(targetid)))
{
switch(random(100))
{
case 0..35:
{
GetPlayerName(targetid, tName, sizeof(tName));
KillTimer(SecdonsToJail[targetid]);
TryingArrested[targetid] = 0;
SetPlayerWantedLevel(targetid, 3);
SetPlayerColor(targetid, COLOR_YELLOW);
format(string,sizeof(string), "{808000}%s(%d) {FFFFFF}has {808000}escaped {FFFFFF}from his HANDCUFFS!! {808000}(Being Arrested)", tName,targetid);
SendClientMessageToAll(-1, string);
GameTextForPlayer(targetid, "~g~ESCAPED ~W~FROM ~R~ARRESTED!!", 5000, 5);
}
case 36..100:
{
if(ArrestReward > GetPlayerCash(playerid))
GetPlayerName(targetid, tName, sizeof(tName));
GetPlayerName(playerid, pName, sizeof(pName));
TryingArrested[targetid] = 0;
ResetPlayerWeapons(targetid);
format(string, sizeof(string), "{808000}%s(%d) {ffffff}has been {808000}ARRESTED {ffffff}by {00FFFF}S.W.A.T %s(%d){ffffff}!! Wanted Level: {00FFFF}%d.", tName,targetid, pName,playerid,GetPlayerWantedLevel(targetid));
SendClientMessageToAll(yellow, string);
format(string, sizeof(string), "~y~ARRESTED BY %s(%d)~n~~W~YOU LOST ~R~$%d", pName, playerid, -ArrestReward);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "~g~ARRESTED ~y~%s(%d)~n~~W~YOU GOT ~R~$%d", tName, targetid, ArrestReward);
GameTextForPlayer(playerid, string, 4000, 5);
format(string, sizeof(string), "{808000}%s(%d) {ffffff}has {ff0000}failed {ffffff}to escaped from his Handcuffs!! {808000}(Being Arrested)", tName,targetid);
SendClientMessageToAll(yellow, string);
GivePlayerMoney(targetid, -ArrestReward);
GivePlayerMoney(playerid, ArrestReward);
}
}
}
else SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}You can use this command only while being cuffed or arrested.");
}
return 1;
}