Converting to zcmd
#7

PHP код:
CMD:bet(playerid,params[])
{
    new 
option[64],string[128], amount;
    new 
idx GetPlayerVirtualWorld(playerid)-100;
    if(
BizInfo[idx][bType] == 7)
         {
              if(!
IsAtRLTable(playerid))
               {
                   
SendClientMessage(playeriderror"You are not near a Roulette table!");
                   return 
1;
            }
               new 
ball random(4);
            if(
sscanf(params"s[8]i"option,amount)) return SendClientMessage(playeriderror"Usage: /bet [Red/Black][$Amount]");
            if(
amount || amount 50000) return SendClientMessage(playeriderror"Bet can't be below $1 or above $50,000!");
            if(!
strcmp(option"red"true))
            {
                
                if(
ball == 1)
                   {
                    
format(stringsizeof(string), "* %s bets on red and won."GetName(playerid));
                    
ProxDetector(5.0playeridstring, -1);
                    
format(stringsizeof(string), "* You won $%d."amount);
                    
SendClientMessage(playerid, -1string);
                    
pInfo[playerid][Cash] += amount;
                    
GivePlayerCash(playeridamount);
                    
BizInfo[idx][bMoney] -= amount;
                }
                else
                {
                       
format(stringsizeof(string), "* %s bets on red and lost.",  GetName(playerid));
                    
ProxDetector(5.0playeridstring,-1);
                    
format(stringsizeof(string), "* You lost $%d."amount);
                    
SendClientMessage(playerid, -1string);
                     
pInfo[playerid][Cash] -= amount;
                     
GivePlayerCash(playerid, -amount);
                    
BizInfo[idx][bMoney] += amount;
                }
            if(!
strcmp(option"black"true))
                {
                    if(
mblack || mblack 50000) return SendClientMessage(playeriderror"Bet can't be below $1 or above $50,000!");
                     if(
ball == 1)
                    {
                        
format(stringsizeof(string), "* %s bets on black and won."GetName(playerid));
                        
ProxDetector(5.0playeridstring, -1);
                        
format(stringsizeof(string), "* You won $%d."amount);
                        
SendClientMessage(playerid, -1string);
                        
pInfo[playerid][Cash] += amount;
                        
GivePlayerCash(playeridamount);
                        
BizInfo[idx][bMoney] -= amount;
                    }
                    else
                    {
                        
format(stringsizeof(string), "* %s bets on black and lost.",  GetName(playerid));
                         
ProxDetector(5.0playeridstring, -1);
                        
format(stringsizeof(string), "* You lost $%d."amount);
                        
SendClientMessage(playerid, -1string);
                         
pInfo[playerid][Cash] -= amount;
                         
GivePlayerMoney(playerid, -amount);
                         
BizInfo[idx][bMoney] += amount;
                    }
                }
            }
        }
    return 
1;

Try this. What I've done is I removed the IsPlayerConnected check, I added the sscanf at the top and used a common variable 'amount' instead of 'mred' and 'mblack'.

EDIT: I've edited the code a bit. Try this
Reply


Messages In This Thread
Converting to zcmd - by 1fret - 11.04.2017, 18:09
Re: Converting to zcmd - by DarkSkull - 11.04.2017, 18:12
Re: Converting to zcmd - by Sew_Sumi - 11.04.2017, 18:49
Re: Converting to zcmd - by 1fret - 11.04.2017, 19:40
Re: Converting to zcmd - by DarkSkull - 11.04.2017, 22:10
Re: Converting to zcmd - by 1fret - 11.04.2017, 22:42
Re: Converting to zcmd - by DarkSkull - 11.04.2017, 22:55
Re: Converting to zcmd - by 1fret - 11.04.2017, 23:17
Re: Converting to zcmd - by DarkSkull - 11.04.2017, 23:24
Re: Converting to zcmd - by Sew_Sumi - 12.04.2017, 00:14

Forum Jump:


Users browsing this thread: 1 Guest(s)