SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/09/2019, 04:37 PM   #1
RedRex
Huge Clucker
 
RedRex's Avatar
 
Join Date: Jan 2016
Location: Portugal <3
Posts: 496
Reputation: 29
Question A Command..

What's wrong with this command? I can pay the bail of my jail but another player cannot pay the ticket for my jail why?!

The command..
PHP Code:
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),playeridMoneyFor[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;

PHP Code:
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],id;
    
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[id] = 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;

__________________
RedRex's Cops and Robbers
RCNR Soon
We are working on it. Just wait us!! Soon updating to hosted tap after finished.
RedRex is offline   Reply With Quote
Old 08/09/2019, 05:11 PM   #2
CheezIt
Big Clucker
 
CheezIt's Avatar
 
Join Date: Apr 2017
Posts: 182
Reputation: 17
Default Re: A Command..

You're placing "playerid" in places where "id" should be
__________________
I'd like to bring back my old CNR server that was created from scratch & hosted years ago. I'll host & update everything (including the website & forum). You would pay for hosted tab and help manage the community. PM me if you're interested!
CheezIt is offline   Reply With Quote
Old 09/09/2019, 01:07 AM   #3
saffierr
High-roller
 
saffierr's Avatar
 
Join Date: Jul 2013
Location: GetPlayerGirlHouse(targetplayer);
Posts: 1,151
Reputation: 39
Default Re: A Command..

You might as well put this code under the 'new ....;' definitions.
PHP Code:
MoneyForBail[playerid] = random(7000) + 1000;
    
MoneyFor[playerid] = MoneyForBail[playerid]; 
Use 'MoneyForBail[id]' as CheezeIt mentioned.
__________________
Quote:
if(IsPlayerConnected(playerid))
possibly the worst 'if' check ever seen.
saffierr is offline   Reply With Quote
Old 09/09/2019, 04:07 PM   #4
RedRex
Huge Clucker
 
RedRex's Avatar
 
Join Date: Jan 2016
Location: Portugal <3
Posts: 496
Reputation: 29
Default Re: A Command..

Look, I've do it.. I can bail myself but another player cannot pay the bail of my jail why?


PHP Code:
CMD:bail(playeridparams[])
{
    new 
idpName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],string[170];
    
MoneyForBail[playerid] = random(8000) + 1000
__________________
RedRex's Cops and Robbers
RCNR Soon
We are working on it. Just wait us!! Soon updating to hosted tap after finished.
RedRex is offline   Reply With Quote
Old 09/09/2019, 09:30 PM   #5
saffierr
High-roller
 
saffierr's Avatar
 
Join Date: Jul 2013
Location: GetPlayerGirlHouse(targetplayer);
Posts: 1,151
Reputation: 39
Default Re: A Command..

If you would read what we've said...
Use 'MoneyForBail[id]' instead of 'MoneyForBail[playerid]'.
__________________
Quote:
if(IsPlayerConnected(playerid))
possibly the worst 'if' check ever seen.
saffierr is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 1 20/04/2018 12:12 PM
[Plugin] mcmd Command Engine - Plugin based command processing Mellnik Plugin Development 108 08/05/2016 01:55 PM
i had this command in my gamemode, when i type this in game,it tells server unknow command? Chrisli520 Scripting Help 3 24/11/2013 10:02 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 03:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 05:19 AM


All times are GMT. The time now is 03:45 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.