21.07.2015, 17:20
Hello, I downloaded Dicebet Command.
When you /dicebet [amount] it rolls a dice ..
you may win the money or loose..
but there is one problem..
if you win money, it gives you them money but then automaticly takes it back..
Same with loosing, it takes money from you but then returns it to you immedietly.
How to fix it?
When you /dicebet [amount] it rolls a dice ..
you may win the money or loose..
but there is one problem..
if you win money, it gives you them money but then automaticly takes it back..
Same with loosing, it takes money from you but then returns it to you immedietly.
How to fix it?
Код:
CMD:dicebet(playerid, params[]){ new bet; if (sscanf(params, "i",bet)) { SendClientMessage(playerid,COLOR_WHITE, "Usage: \"/Dice <amount to bet>\""); } else { if (bet<1) { SendClientMessage(playerid,COLOR_WHITE, "Are you kidding me? Bet a positive amount."); } else if (bet>1000000) { SendClientMessage(playerid,COLOR_WHITE, "You can't bet more than 1,000,000$."); } else { new Cash=GetPlayerMoney(playerid); if (Cash<bet) { new string[128]; format(string,sizeof(string),"No Money - No Bet. Your Cash: $%i",Cash); SendClientMessage(playerid,COLOR_WHITE,string); } else { new NumberDrawn11,NumberDrawn12,NumberDouble1,NumberDrawn21,NumberDrawn22,NumberDouble2,Winner; NumberDrawn11=random(6)+1; NumberDrawn12=random(6)+1; if (NumberDrawn11==NumberDrawn12) NumberDouble1=NumberDrawn11; NumberDrawn21=random(6)+1; NumberDrawn22=random(6)+1; if (NumberDrawn21==NumberDrawn22) NumberDouble2=NumberDrawn21; if (NumberDrawn11+NumberDrawn12>NumberDrawn21+NumberDrawn22) { Winner=1; } else if (NumberDrawn11+NumberDrawn12<NumberDrawn21+NumberDrawn22) { Winner=2; } else { if (NumberDouble1>NumberDouble2) Winner=1; else if (NumberDouble1<NumberDouble2) Winner=2; } new string[64]; format(string,sizeof(string),"Numbers Diced 1: %d %d",NumberDrawn11,NumberDrawn12); SendClientMessage(playerid,COLOR_CYAN,string); format(string,sizeof(string),"Numbers Diced 2: %d %d",NumberDrawn21,NumberDrawn22); SendClientMessage(playerid,COLOR_CYAN,string); if (Winner==1) { if (NumberDouble1>0) { format(string,sizeof(string),"You won $%d, a double!",bet*2); SendClientMessage(playerid,COLOR_CYAN,string); SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")+bet*2); GivePlayerMoney(playerid,bet*2); } else { format(string,sizeof(string),"You won $%d",bet); SendClientMessage(playerid,COLOR_LIME,string); SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")+bet); GivePlayerMoney(playerid,bet); } } else if (Winner==2) { format(string,sizeof(string),"You lost $%d",bet); SendClientMessage(playerid,COLOR_RED,string); SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")-bet); GivePlayerMoney(playerid,-bet); } else if (Winner==0) { format(string,sizeof(string),"Draw",bet); SendClientMessage(playerid,COLOR_WHITE,string); } } } } return 1; }