#1

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...

PHP код:
CMD:bail(playeridparams[])
{
    
MoneyForBail[playerid] = random(7000) + 1000;
    
MoneyFor[playerid] = MoneyForBail[playerid];
    new 
targetidpName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],string[170];
    
GetPlayerName(playeridpNamesizeof(pName));
    
GetPlayerName(targetidtNamesizeof(tName));
    if(
sscanf(params"u"playerid)) return SendClientMessage(playeridCOLOR_WHITE"{FF0000}Syntax: /Bail <playerid>"); //should be targetid, not playerid
     
if(PlayerInfo[targetid][pJailed] == 0) return SendClientMessage(playeridred"{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(playeridCOLOR_RED"{FF0000}Error: {FFFFFF}You don't have engouh money to bail yourself."), PlayerPlaySound(playerid54060.00.05.0);
                   
format(fstr2sizeof(fstr2), "{FFFFFF}[JAIL RELEASE]: {FFD700}%s(%d) {FFFFFF}has been released from {33FF33}Jail{FFFFFF}. Bail paid ({33FF33}$%d{FFFFFF})!"GetName(playerid),playeridMoneyForBail[playerid]);
                
SendClientMessageToAll(COLOR_DODGERBLUEfstr2);
                
BailPlayer[playerid] = 0;
                
TextDrawHideForPlayer(playeridTextdraw0);
                
TextDrawHideForPlayer(playeridTextdraw1);
                
TextDrawHideForPlayer(playeridTextdraw2);
                
TextDrawHideForPlayer(playeridTextdraw3);
                
TextDrawHideForPlayer(playeridTextdraw9);
                
escapeText(playerid);
                
KillTimer(pJailTimerID[playerid]);
                 
KillTimer(SendToJail[playerid]);
                
KillTimer(pJailCount[playerid]);
                 
BeginArrested[playerid] = 0;
                  
MoneyForBail[playerid] = 0;
                
SetPlayerInterior(playerid3);
                
PlayerInfo[playerid][pJailed] = 0;
                
SetPlayerPos(playerid199.4501,169.1128,1003.0234);
                
SetPlayerHealth(playerid100);
                
GivePlayerMoney(playerid, -MoneyFor[playerid]);
                
OtherMenuBail[targetid] = 0;
                   
format(fstrsizeof(fstr), "[DISPATCH]: Suspect %s[%d) has bail himself."pNameplayerid);
                
CopRadio(COLOR_DODGERBLUEfstr);
               }
        }
        else if(
OtherMenuBail[targetid] == 1)
        {
            if(
MoneyForBail[playerid] > GetPlayerCash(targetid))
            {
                  if(
GetPlayerMoney(targetid) > MoneyForBail[playerid])
                  {
                        
format(stringsizeof(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,playeridMoneyForBail[playerid]);
                        
SendClientMessageToAll(COLOR_DODGERBLUEstring);
                          
BailPlayer[playerid] = 0;
                          
TextDrawHideForPlayer(playeridTextdraw0);
                          
TextDrawHideForPlayer(playeridTextdraw1);
                        
TextDrawHideForPlayer(playeridTextdraw2);
                        
TextDrawHideForPlayer(playeridTextdraw3);
                        
TextDrawHideForPlayer(playeridTextdraw9);
                        
KillTimer(pJailTimerID[playerid]);
                         
KillTimer(SendToJail[playerid]);
                        
KillTimer(pJailCount[playerid]);
                        
BeginArrested[playerid] = 0;
                        
MoneyForBail[playerid] = 0;
                        
SetPlayerInterior(playerid3);
                        
PlayerInfo[playerid][pJailed] = 0;
                        
SetPlayerPos(playerid199.4501,169.1128,1003.0234);
                         
SetPlayerHealth(playerid100);
                         
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,playeridpJailCount[playerid]);
                        
SendClientMessage(playerid, -1string);
                    }
            }
            else
            {
                   
SendClientMessage(playeridCOLOR_RED"{FF0000}Error: {FFFFFF}You don't have engouh money to bail this player.");
                
PlayerPlaySound(playerid54060.00.05.0);
            }
        }
    }
    return 
1;

This public for jail time:

PHP код:
forward pJailTimer(playerid);
public 
pJailTimer(playerid)
{
    
MoneyFor[playerid] = MoneyForBail[playerid];
    
TextDrawHideForPlayer(playeridTextdraw3);
    
RemovePlayerAttachedObject(playerid9);
    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_NONE);
    
PlayerInfo[playerid][pJailed] = 1;
    
pJailCount[playerid]--;
    new 
string[128],targetid;
    
format(stringsizeof(string), "%d"pJailCount[playerid]);
    
TextDrawSetString(Textdraw1string);
    
TextDrawShowForPlayer(playeridTextdraw3);
     
format(stringsizeof(string), "%d"MoneyFor[playerid]);
     
TextDrawSetString(Textdraw3string);
    
SetPlayerInterior(playerid3);
    
SetPlayerHealth(playerid10000000);
    
KillTimer(SendToJail[playerid]);
    
TextDrawShowForPlayer(playeridTextdraw0);
    
TextDrawShowForPlayer(playeridTextdraw1);
    
TextDrawShowForPlayer(playeridTextdraw2);
    
TextDrawShowForPlayer(playeridTextdraw3);
    
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"50005);
        
KillTimer(pJailTimerID[playerid]);
        
KillTimer(SendToJail[playerid]);
        
KillTimer(pJailCount[playerid]);
        return 
1;
    }
    return 
1;

Reply
#2

Don't use playerid because obviously to bail another player.

Replace `playerid` by `targetid` inside the sscanf AND the target id's interactions.

(like the pJailed variable, replace the playerid with targetid. (sorry for not providing code, I am on phone))
Reply
#3

I've replaced the sscanf but It still not work why?
Reply
#4

Define "not working"? Did you try /bail (another id =/= playerid)?

By the way, I see 0 timers set.
Reply
#5

Sir all timers are worked fine! I did not said the problem of timers !! My problem Just I want such as If You are in Jailed and someone wanna paid the amount of your jailed! they will say his name in text ! Did u understand me? Such as %s(%d) You have paid the bail amount of player %s(%d) but if the enemy player wanna paid the amount by himself it's worked succesfuly for me! I just want an idea how to do that? like if someone wanna pay my jail amount!!
Reply
#6

Then you should make a check, if targetid == playerid then proceed, make an else statement and put the code for paying the to another person.

To make it short, your "targetid" has to be included in its respective variables, because obviously it is set to 0 and useless. (beside the GetPlayerName you've put)
Reply
#7

It's not work buddy!!
Reply
#8

Show your new code.
Reply
#9

Hi thanks for replying but i've changing the full code! I've making it and everything are worked successfuly but the problem is differnet player when checking the time left for jail for a player he cannot why? I mean when you type /Bail [Your ID] You will see the timeleft but when a differnt player type /Bail [Your ID] He cannot checking the timeleft why? they sent him 0 message's. Also when a differnt player wanna bail you he cannot why...

Full code

PHP код:
CMD:bail(playeridparams[])
{
    
MoneyForBail[playerid] = random(7000) + 1000;
    
MoneyFor[playerid] = MoneyForBail[playerid];
    new 
idpName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],string[170];
    
GetPlayerName(playeridpNamesizeof(pName));
    
GetPlayerName(idtNamesizeof(tName));
    if(
sscanf(params"u"id)) return SendClientMessage(playeridCOLOR_WHITE"{FF0000}Syntax: /Bail <playerid>");
    if(
PlayerInfo[id][pJailed] == 0) return SendClientMessage(playeridred"{FF0000}Error: This player is not in jail.");
    if(
PlayerInfo[playerid][pJailed] == 1)
    {
         if(
BailPlayer[playerid] == 1)
           {
                   if(
MoneyForBail[playerid] > GetPlayerCash(playerid))
                {
                    if(
id == PlayerInfo[playerid][pJailed] && 1)
                    {
                           
MoneyFor[playerid] = MoneyForBail[playerid];
                        if(
GetPlayerMoney(playerid) < MoneyForBail[playerid]) return SendClientMessage(playeridCOLOR_RED"{FF0000}Error: {FFFFFF}You don't have engouh money to bail yourself."), PlayerPlaySound(playerid54060.00.05.0);
                           
format(fstr2sizeof(fstr2), "{FFFFFF}[JAIL RELEASE]: {FFD700}%s(%d) {FFFFFF}has been released from {33FF33}Jail{FFFFFF}. Bail paid ({33FF33}$%d{FFFFFF})!"GetName(playerid),playeridMoneyForBail[playerid]);
                        
SendClientMessageToAll(COLOR_DODGERBLUEfstr2);
                        
BailPlayer[playerid] = 0;
                        
TextDrawHideForPlayer(playeridTextdraw0);
                        
TextDrawHideForPlayer(playeridTextdraw1);
                        
TextDrawHideForPlayer(playeridTextdraw2);
                        
TextDrawHideForPlayer(playeridTextdraw3);
                        
TextDrawHideForPlayer(playeridTextdraw9);
                        
escapeText(playerid);
                        
KillTimer(pJailTimerID[playerid]);
                         
KillTimer(SendToJail[playerid]);
                        
KillTimer(pJailCount[playerid]);
                         
BeginArrested[playerid] = 0;
                          
MoneyForBail[playerid] = 0;
                          
escapetime[playerid] = 1;
                        
SetPlayerInterior(playerid3);
                        
PlayerInfo[playerid][pJailed] = 0;
                        
SetPlayerPos(playerid199.4501,169.1128,1003.0234);
                        
SetPlayerHealth(playerid100);
                        
GivePlayerMoney(playerid, -MoneyFor[playerid]);
                        
OtherMenuBail[id] = 0;
                           
format(fstrsizeof(fstr), "[DISPATCH]: Suspect %s[%d) has bail himself."pNameplayerid);
                        
CopRadio(COLOR_DODGERBLUEfstr);
                        return 
1;
                  }
            }
        }
        else
        {
              if(
PlayerInfo[playerid][pJailed] == 1// If the id which he typed is the same as his id
            
{
                
format(fstr2,sizeof(fstr2), "{00BDFF}[Jail Released]: {FFFFFF}%s(%d) has not served their minimum Jail Sentence yet. {FFFFFF}Time left: {0080FF}%d{FFFFFF}."GetName(playerid),playerid,pJailCount[playerid]);
                
SendClientMessage(playerid, -1fstr2);
                return 
1;
               }
               else
               {
                   
format(fstr2,sizeof(fstr2), "{00BDFF}[Jail Released]: {FFFFFF}%s(%d) has not served their minimum Jail Sentence yet. {FFFFFF}Time left: {0080FF}%d{FFFFFF}."GetName(playerid),playerid,pJailCount[playerid]);
                
SendClientMessage(id, -1,fstr2);
               }
        }
        if(
PlayerInfo[playerid][pJailed] == 1)
        {
            if(
id == OtherMenuBail[id] && 1)
            {
                if(
MoneyForBail[playerid] > GetPlayerCash(id))
                {
                      if(
GetPlayerMoney(id) > MoneyForBail[playerid])
                      {
                        
format(fstrsizeof(fstr), "{FFFFFF}[JAIL RELEASE]: {FFD700}%s(%d) {FFFFFF}has been payed the bail for Player {FFD700}%s(%d){FFFFFF}. Bail Paid: ({33FF33}$%d{FFFFFF})!"tName,id,pName,playeridMoneyForBail[playerid]);
                        
SendClientMessageToAll(COLOR_DODGERBLUEfstr);
                        
BailPlayer[playerid] = 0;
                        
TextDrawHideForPlayer(playeridTextdraw0);
                        
TextDrawHideForPlayer(playeridTextdraw1);
                        
TextDrawHideForPlayer(playeridTextdraw2);
                        
TextDrawHideForPlayer(playeridTextdraw3);
                        
TextDrawHideForPlayer(playeridTextdraw9);
                        
KillTimer(pJailTimerID[playerid]);
                        
KillTimer(SendToJail[playerid]);
                        
KillTimer(pJailCount[playerid]);
                        
BeginArrested[playerid] = 0;
                        
MoneyForBail[playerid] = 0;
                        
SetPlayerInterior(playerid3);
                        
PlayerInfo[playerid][pJailed] = 0;
                        
escapetime[playerid] = 1;
                        
SetPlayerPos(playerid199.4501,169.1128,1003.0234);
                        
SetPlayerHealth(playerid100);
                        
OtherMenuBail[playerid] = 0;
                        
GivePlayerMoney(id, -MoneyFor[playerid]);
                    }
             }
            else
              {
                
format(string,sizeof(string), "{00BDFF}[Jail Released]:{FFFFFF}%s(%d) has not served their minimum Jail Sentence yet. {FFFFFF}Time left: {0080FF}%d{FFFFFF}."pName,playeridpJailCount[playerid]);
                  
SendClientMessage(playerid, -1string);
              }
            }
            else
            {
                   
SendClientMessage(playeridCOLOR_RED"{FF0000}Error: {FFFFFF}You don't have engouh money to bail this player.");
                      
PlayerPlaySound(playerid54060.00.05.0);
            }
        }
    }
    return 
1;

Reply
#10

Mate just replace the playerid by id, not all, just understand that : ID, is the jailed player, and playerid, is the one who's paying for. So go check your code and replace accordingly to what you need, playerid by id. I tried to do that but I didn't understand some of your variables. By the way you are using a lot of if statements, which are useless / done twice. I am sorry I cannot touch the code, I am on phone

Код:
if(id == PlayerInfo[playerid][pJailed] && 1)
This means nothing, replace it by this:

Код:
if(PlayerInfo[id][pJailed])
I hope it's a boolean variable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)