05.02.2019, 17:20
Hello... I have creating a command for a bail its worked sucessfuly when I bail myself! but when the different player wanna bail me it's not working why? They sent me 0message's...
This public for jail time:
PHP код:
CMD:bail(playerid, params[])
{
MoneyForBail[playerid] = random(7000) + 1000;
MoneyFor[playerid] = MoneyForBail[playerid];
new targetid, pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],string[170];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(targetid, tName, sizeof(tName));
if(sscanf(params, "u", playerid)) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Syntax: /Bail <playerid>"); //should be targetid, not playerid
if(PlayerInfo[targetid][pJailed] == 0) return SendClientMessage(playerid, red, "{FF0000}Error: This player is not in jail.");
if(PlayerInfo[playerid][pJailed] == 1)
{
if(BailPlayer[playerid] == 1)
{
if(MoneyForBail[playerid] > GetPlayerCash(playerid))
{
MoneyFor[playerid] = MoneyForBail[playerid];
if(GetPlayerMoney(playerid) < MoneyForBail[playerid]) return SendClientMessage(playerid, COLOR_RED, "{FF0000}Error: {FFFFFF}You don't have engouh money to bail yourself."), PlayerPlaySound(playerid, 5406, 0.0, 0.0, 5.0);
format(fstr2, sizeof(fstr2), "{FFFFFF}[JAIL RELEASE]: {FFD700}%s(%d) {FFFFFF}has been released from {33FF33}Jail{FFFFFF}. Bail paid ({33FF33}$%d{FFFFFF})!", GetName(playerid),playerid, MoneyForBail[playerid]);
SendClientMessageToAll(COLOR_DODGERBLUE, fstr2);
BailPlayer[playerid] = 0;
TextDrawHideForPlayer(playerid, Textdraw0);
TextDrawHideForPlayer(playerid, Textdraw1);
TextDrawHideForPlayer(playerid, Textdraw2);
TextDrawHideForPlayer(playerid, Textdraw3);
TextDrawHideForPlayer(playerid, Textdraw9);
escapeText(playerid);
KillTimer(pJailTimerID[playerid]);
KillTimer(SendToJail[playerid]);
KillTimer(pJailCount[playerid]);
BeginArrested[playerid] = 0;
MoneyForBail[playerid] = 0;
SetPlayerInterior(playerid, 3);
PlayerInfo[playerid][pJailed] = 0;
SetPlayerPos(playerid, 199.4501,169.1128,1003.0234);
SetPlayerHealth(playerid, 100);
GivePlayerMoney(playerid, -MoneyFor[playerid]);
OtherMenuBail[targetid] = 0;
format(fstr, sizeof(fstr), "[DISPATCH]: Suspect %s[%d) has bail himself.", pName, playerid);
CopRadio(COLOR_DODGERBLUE, fstr);
}
}
else if(OtherMenuBail[targetid] == 1)
{
if(MoneyForBail[playerid] > GetPlayerCash(targetid))
{
if(GetPlayerMoney(targetid) > MoneyForBail[playerid])
{
format(string, sizeof(string), "{FFFFFF}[JAIL RELEASE]: {FFD700}%s(%d) {FFFFFF}has been payed the bail for Player {FFD700}%s(%d){FFFFFF}. Bail Paid: ({33FF33}$%d{FFFFFF})!", tName,targetid,pName,playerid, MoneyForBail[playerid]);
SendClientMessageToAll(COLOR_DODGERBLUE, string);
BailPlayer[playerid] = 0;
TextDrawHideForPlayer(playerid, Textdraw0);
TextDrawHideForPlayer(playerid, Textdraw1);
TextDrawHideForPlayer(playerid, Textdraw2);
TextDrawHideForPlayer(playerid, Textdraw3);
TextDrawHideForPlayer(playerid, Textdraw9);
KillTimer(pJailTimerID[playerid]);
KillTimer(SendToJail[playerid]);
KillTimer(pJailCount[playerid]);
BeginArrested[playerid] = 0;
MoneyForBail[playerid] = 0;
SetPlayerInterior(playerid, 3);
PlayerInfo[playerid][pJailed] = 0;
SetPlayerPos(playerid, 199.4501,169.1128,1003.0234);
SetPlayerHealth(playerid, 100);
EnemyBail[targetid] = 0;
OtherMenuBail[playerid] = 0;
GivePlayerMoney(targetid, -MoneyFor[playerid]);
}
else
{
format(string,sizeof(string), "{00BDFF}[Jail]: [ERROR]: {FFFFFF}%s(%d) has not served their minimum Jail Sentence yet. {FFFFFF}Time left: {0080FF}%d{FFFFFF}.", pName,playerid, pJailCount[playerid]);
SendClientMessage(playerid, -1, string);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "{FF0000}Error: {FFFFFF}You don't have engouh money to bail this player.");
PlayerPlaySound(playerid, 5406, 0.0, 0.0, 5.0);
}
}
}
return 1;
}
PHP код:
forward pJailTimer(playerid);
public pJailTimer(playerid)
{
MoneyFor[playerid] = MoneyForBail[playerid];
TextDrawHideForPlayer(playerid, Textdraw3);
RemovePlayerAttachedObject(playerid, 9);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
PlayerInfo[playerid][pJailed] = 1;
pJailCount[playerid]--;
new string[128],targetid;
format(string, sizeof(string), "%d", pJailCount[playerid]);
TextDrawSetString(Textdraw1, string);
TextDrawShowForPlayer(playerid, Textdraw3);
format(string, sizeof(string), "%d", MoneyFor[playerid]);
TextDrawSetString(Textdraw3, string);
SetPlayerInterior(playerid, 3);
SetPlayerHealth(playerid, 10000000);
KillTimer(SendToJail[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2);
TextDrawShowForPlayer(playerid, Textdraw3);
escaped[playerid] = 1;
escape(playerid);
if(pJailCount[playerid] == 0)
{
BailPlayer[playerid] = 1;
OtherMenuBail[targetid] = 1;
SendClientMessage(playerid, -1, "Jail Sentence served! Type {0080FF}/bail {FFFFFF}to get out.");
GameTextForPlayer(playerid, "~B~/BAIL TO LEAVE ~R~JAILED", 5000, 5);
KillTimer(pJailTimerID[playerid]);
KillTimer(SendToJail[playerid]);
KillTimer(pJailCount[playerid]);
return 1;
}
return 1;
}