11.03.2014, 12:42
So i have Lottery bussiness but owner can't set jackpot and start it
CMD
Withdraw and EntryFee is working
CMD
PHP код:
CMD:biz(playerid, params[])
{
new string[128], choice[32], amount;
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pBizKey] == 999)
{
SendClientMessage(playerid, COLOR_GREY, "You don't own a business");
return 1;
}
if(PlayerInfo[playerid][pInBiz] != PlayerInfo[playerid][pBizKey])
{
SendClientMessage(playerid, COLOR_GREY, "You need to be inside your business to do this");
return 1;
}
new biz = PlayerInfo[playerid][pBizKey];
if(sscanf(params, "s[32]d", choice, amount))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /biz [name]");
SendClientMessage(playerid, COLOR_GRAD1, "Available names: Withdraw, EntryFee, Restock");
if(BizInfo[biz][bType] == 8)
{
SendClientMessage(playerid, COLOR_GRAD1, "Available names: AddJackpot, Startlotto");
}
if(BizInfo[biz][bType] == 6)
{
SendClientMessage(playerid, COLOR_GRAD1, "Available names: Mass");
}
return 1;
}
if(strcmp(choice,"Withdraw",true) == 0)
{
if(!strlen(params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /biz Withdraw [amount]");
format(string, sizeof(string), "You currently have $%d in your business till", BizInfo[biz][bTill]);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
if(amount > BizInfo[biz][bTill])
{
SendClientMessage(playerid, COLOR_GREY, " You don't have that much in your business till");
return 1;
}
new left = BizInfo[biz][bTill]-amount;
BizInfo[biz][bTill] = left;
format(string, sizeof(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(playerid, COLOR_WHITE, "USAGE: /biz EntryFee [amount]");
return 1;
}
if(amount > 100 || amount < 0)
{
SendClientMessage(playerid, COLOR_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(owner, BizInfo[biz][bOwner], 0, strlen(BizInfo[biz][bOwner]), 255);
strmid(name, BizInfo[biz][bName], 0, strlen(BizInfo[biz][bName]), 255);
format(VString,sizeof(VString),"%s \nOwner: %s \nEntry fee: $%d", name,owner,BizInfo[biz][bFee]);
BizLabel[biz] = Text3D:CreateDynamic3DTextLabel(VString, COLOR_GREEN, BizInfo[biz][bLocation_x], BizInfo[biz][bLocation_y], BizInfo[biz][bLocation_z]+0.1, 20, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, BizInfo[biz][bPVW], BizInfo[biz][bPInt], -1, 100.0);
format(string, sizeof(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(playerid, COLOR_WHITE, "USAGE: /biz Restock [amount]");
format(string, sizeof(string), "You currently have %d products in your business", BizInfo[biz][bProducts]);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
new calc = amount+BizInfo[biz][bProducts];
if(calc > 500)
{
SendClientMessage(playerid, COLOR_GREY, " You can't restock that much");
return 1;
}
if(amount > PlayerInfo[playerid][pProducts])
{
SendClientMessage(playerid, COLOR_GREY, " You don't have that much");
return 1;
}
BizInfo[biz][bProducts] = calc;
format(string, sizeof(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(string, sizeof(string), "You added $%d to the jackpot", amount);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
BizInfo[biz][bLottoJackpot] += amount;
return 1;
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this!");
}
}
else if(strcmp(choice,"StartLotto",true) == 0)
{
if(PlayerInfo[playerid][pBizKey] == 999)
{
SendClientMessage(playerid, COLOR_GREY, " You don't own a lotto agency");
return 1;
}
if(BizInfo[PlayerInfo[playerid][pBizKey]][bType] != 8 )
{
SendClientMessage(playerid, COLOR_GREY, " You don't own a lotto agency");
return 1;
}
if(BizInfo[PlayerInfo[playerid][pBizKey]][bLottoTime] > 0 )
{
SendClientMessage(playerid, COLOR_GREY, " You already had a draw recently");
return 1;
}
new bizname[25];
strmid(bizname, BizInfo[PlayerInfo[playerid][pBizKey]][bName], 0, strlen(BizInfo[PlayerInfo[playerid][pBizKey]][bName]), 255);
new location[MAX_ZONE_NAME];
Get2DZone(location, MAX_ZONE_NAME, BizInfo[PlayerInfo[playerid][pBizKey]][bLocation_x], BizInfo[PlayerInfo[playerid][pBizKey]][bLocation_y], BizInfo[PlayerInfo[playerid][pBizKey]][bLocation_z]);
format(string, sizeof(string), "Lottery: %s will have a draw in 5 minutes. Jackpot: %d", bizname, BizInfo[PlayerInfo[playerid][pBizKey]][bLottoJackpot]);
SendClientMessageToAll(COLOR_RED, string);
format(string, sizeof(string), "Lottery: Buy your tickets from the lotto agency located in %s",location);
SendClientMessageToAll(COLOR_RED, string);
// SetTimerEx("StartLotto", 3000, 0, "d", PlayerInfo[playerid][pBizKey]);
SetTimerEx("StartLotto", 300000, 0, "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(playerid, COLOR_GREY, " You don't own a phone company");
return 1;
}
if(BizInfo[PlayerInfo[playerid][pBizKey]][bType] != 6 )
{
SendClientMessage(playerid, COLOR_GREY, " You don't own a phone company");
return 1;
}
if(BizInfo[PlayerInfo[playerid][pBizKey]][bLottoTime] > 0 )
{
SendClientMessage(playerid, COLOR_GREY, " You already sent a mass recently");
return 1;
}
if(!strlen(params))
{
SendClientMessage(playerid, COLOR_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(playerid, COLOR_GREY, "USAGE: /mass [Number] [Message]");
return 1;
}
format(string, sizeof(string), "[SMS Inbox] Sender: %d",number);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "Message: %s",result);
SendClientMessageToAll(COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_WHITE, "Text Message Delivered");
BizInfo[biz][bLottoTime] = 1;
return 1;
}
else { return 1; }
}
return 1;
}