Lottery System
#1

So i have Lottery bussiness but owner can't set jackpot and start it

CMD
PHP код:
CMD:biz(playeridparams[])
    {
    new 
string[128], choice[32], amount;
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pBizKey] == 999)
            {
                   
SendClientMessage(playeridCOLOR_GREY"You don't own a business");
                   return 
1;
               }
            if(
PlayerInfo[playerid][pInBiz] != PlayerInfo[playerid][pBizKey])
            {
                   
SendClientMessage(playeridCOLOR_GREY"You need to be inside your business to do this");
                   return 
1;
               }
               new 
biz PlayerInfo[playerid][pBizKey];
            if(
sscanf(params"s[32]d"choiceamount))
            {
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /biz [name]");
                    
SendClientMessage(playeridCOLOR_GRAD1"Available names: Withdraw, EntryFee, Restock");
                    if(
BizInfo[biz][bType] == 8)
                    {
                        
SendClientMessage(playeridCOLOR_GRAD1"Available names: AddJackpot, Startlotto");
                    }
                    if(
BizInfo[biz][bType] == 6)
                    {
                        
SendClientMessage(playeridCOLOR_GRAD1"Available names: Mass");
                    }
                    return 
1;
            }
            if(
strcmp(choice,"Withdraw",true) == 0)
            {
                if(!
strlen(params))
                {
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /biz Withdraw [amount]");
                    
format(stringsizeof(string), "You currently have $%d in your business till"BizInfo[biz][bTill]);
                    
SendClientMessage(playeridCOLOR_YELLOWstring);
                    return 
1;
                }
                if(
amount BizInfo[biz][bTill])
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You don't have that much in your business till");
                    return 
1;
                }
                new 
left BizInfo[biz][bTill]-amount;
                
BizInfo[biz][bTill] = left;
                
format(stringsizeof(string), "You took $%d from your business"amount);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                
PlayerInfo[playerid][pCash] += amount;
                
GivePlayerCash(playerid,amount);
                return 
1;
            }
            else if(
strcmp(choice,"EntryFee",true) == 0)
            {
                if(!
strlen(params))
                {
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /biz EntryFee [amount]");
                    return 
1;
                }
                if(
amount 100 || amount 0)
                {
                    
SendClientMessage(playeridCOLOR_GREY"   The entry fee must be between $0 - $100");
                    return 
1;
                }
                
BizInfo[biz][bFee] = amount;
                
DestroyDynamic3DTextLabel(BizLabel[biz]);
                 new 
VString[255];
                new 
name[25], owner[MAX_PLAYER_NAME];
                   
strmid(ownerBizInfo[biz][bOwner], 0strlen(BizInfo[biz][bOwner]), 255);
                
strmid(nameBizInfo[biz][bName], 0strlen(BizInfo[biz][bName]), 255);
                   
format(VString,sizeof(VString),"%s \nOwner: %s \nEntry fee: $%d"name,owner,BizInfo[biz][bFee]);
                
BizLabel[biz] = Text3D:CreateDynamic3DTextLabel(VStringCOLOR_GREENBizInfo[biz][bLocation_x], BizInfo[biz][bLocation_y], BizInfo[biz][bLocation_z]+0.120INVALID_PLAYER_IDINVALID_VEHICLE_ID0BizInfo[biz][bPVW], BizInfo[biz][bPInt], -1100.0);
                
format(stringsizeof(string), "You have set your business entry fee to $%d"amount);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                return 
1;
            }
            else if(
strcmp(choice,"Restock",true) == 0)
            {
                if(!
strlen(params))
                {
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /biz Restock [amount]");
                    
format(stringsizeof(string), "You currently have %d products in your business"BizInfo[biz][bProducts]);
                    
SendClientMessage(playeridCOLOR_YELLOWstring);
                    return 
1;
                }
                new 
calc amount+BizInfo[biz][bProducts];
                if(
calc 500)
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You can't restock that much");
                    return 
1;
                }
                if(
amount PlayerInfo[playerid][pProducts])
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You don't have that much");
                    return 
1;
                }
                
BizInfo[biz][bProducts] = calc;
                
format(stringsizeof(string), "You have restocked your business.");
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                
PlayerInfo[playerid][pProducts] -= amount;
                return 
1;
            }
            else if(
strcmp(choice,"AddJackpot",true) == 0)
            {
                if(
GetPlayerCash(giveplayerid) > 0)
                {
                
PlayerInfo[playerid][pCash] -= amount;
                
GivePlayerCash(playerid,-amount);
                
format(stringsizeof(string), "You added $%d to the jackpot"amount);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                
BizInfo[biz][bLottoJackpot] += amount;
                return 
1;
                }
                else
                {
                
SendClientMessageEx(playeridCOLOR_GRAD4"You don't have the cash for this!");
                }
            }
            else if(
strcmp(choice,"StartLotto",true) == 0)
            {
                if(
PlayerInfo[playerid][pBizKey] == 999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You don't own a lotto agency");
                    return 
1;
                }
                if(
BizInfo[PlayerInfo[playerid][pBizKey]][bType] != )
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You don't own a lotto agency");
                    return 
1;
                }
                if(
BizInfo[PlayerInfo[playerid][pBizKey]][bLottoTime] > )
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You already had a draw recently");
                    return 
1;
                }
                new 
bizname[25];
                
strmid(biznameBizInfo[PlayerInfo[playerid][pBizKey]][bName], 0strlen(BizInfo[PlayerInfo[playerid][pBizKey]][bName]), 255);
                new 
location[MAX_ZONE_NAME];
                
Get2DZone(locationMAX_ZONE_NAMEBizInfo[PlayerInfo[playerid][pBizKey]][bLocation_x], BizInfo[PlayerInfo[playerid][pBizKey]][bLocation_y], BizInfo[PlayerInfo[playerid][pBizKey]][bLocation_z]);
                
format(stringsizeof(string), "Lottery: %s will have a draw in 5 minutes. Jackpot: %d"biznameBizInfo[PlayerInfo[playerid][pBizKey]][bLottoJackpot]);
                
SendClientMessageToAll(COLOR_REDstring);
                
format(stringsizeof(string), "Lottery: Buy your tickets from the lotto agency located in %s",location);
                
SendClientMessageToAll(COLOR_REDstring);
//                SetTimerEx("StartLotto", 3000, 0, "d", PlayerInfo[playerid][pBizKey]);
                
SetTimerEx("StartLotto"3000000"d"PlayerInfo[playerid][pBizKey]);
                
BizInfo[biz][bLottoTime] = 1;
                return 
1;
            }
            else if(
strcmp(choice,"Mass",true) == 0)
            {
                new 
number;
                if(
PlayerInfo[playerid][pBizKey] == 999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You don't own a phone company");
                    return 
1;
                }
                if(
BizInfo[PlayerInfo[playerid][pBizKey]][bType] != )
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You don't own a phone company");
                    return 
1;
                }
                if(
BizInfo[PlayerInfo[playerid][pBizKey]][bLottoTime] > )
                {
                    
SendClientMessage(playeridCOLOR_GREY"   You already sent a mass recently");
                    return 
1;
                }
                    if(!
strlen(params))
                {
                    
SendClientMessage(playeridCOLOR_GREY"USAGE: /biz Mass [Number] [Message]");
                    return 
1;
                }
                new 
idx;
                new 
offset idx;
                
number strvalEx(params);
                new 
length strlen(params);
                while ((
idx length) && (params[idx] <= ' '))
                {
                    
idx++;
                }
                
                new 
result[96];
                while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                {
                    
result[idx offset] = params[idx];
                    
idx++;
                }
                
result[idx offset] = EOS;
                if(!
strlen(result))
                {
                    
SendClientMessage(playeridCOLOR_GREY"USAGE: /mass [Number] [Message]");
                    return 
1;
                }
                
format(stringsizeof(string), "[SMS Inbox] Sender: %d",number);
                
SendClientMessageToAll(COLOR_WHITEstring);
                
format(stringsizeof(string), "Message: %s",result);
                
SendClientMessageToAll(COLOR_WHITEstring);
                
SendClientMessage(playeridCOLOR_WHITE"Text Message Delivered");
                
BizInfo[biz][bLottoTime] = 1;
                return 
1;
            }
            else { return 
1; }
        }
        return 
1;
    } 
Withdraw and EntryFee is working
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)