CMD:dice(playerid,params[]){
LoggedCMD
if(!IsPlayerInRangeOfPoint(playerid,2,214.6529,1828.4265,2001.0857)) return MSG(playerid,C_RED,"[Error] {ff9999}You're not in the right place to use this command.");
if(sscanf(params,"sd",MiniString,param[0])) return MSG(playerid,C_RED,"[Error] {FF9999}/Dice [1-6/Even/Odd] [Amount]");
if(param[0]>DB[playerid][Money] || param[0]<1) return MSG(playerid,C_RED,"[Error] {Ff9999}Invalid Amount.");
if(strcmp(MiniString,"1",true) && strcmp(MiniString,"2",true) && strcmp(MiniString,"3",true) && strcmp(MiniString,"4",true) && strcmp(MiniString,"5",true) && strcmp(MiniString,"6",true) && strcmp(MiniString,"Even",true) && strcmp(MiniString,"Odd",true)) return MSG(playerid,C_RED,"[Error] {ff9999]/Dice [1-6/Even/Odd]");
new PlayerBet[MAX_PLAYERS],DiceResult[MAX_PLAYERS],bool:WonX2[MAX_PLAYERS],bool:WonX6[MAX_PLAYERS];
if(!strcmp(MiniString,"1",true)){PlayerBet[playerid] = 1;}
if(!strcmp(MiniString,"2",true)){PlayerBet[playerid] = 2;}
if(!strcmp(MiniString,"3",true)){PlayerBet[playerid] = 3;}
if(!strcmp(MiniString,"4",true)){PlayerBet[playerid] = 4;}
if(!strcmp(MiniString,"5",true)){PlayerBet[playerid] = 5;}
if(!strcmp(MiniString,"6",true)){PlayerBet[playerid] = 6;}
if(!strcmp(MiniString,"Even",true)){PlayerBet[playerid] = 7;}
if(!strcmp(MiniString,"Odd",true)){PlayerBet[playerid] = 8;}
new rand = random(2);
switch(rand){
case 0: DiceResult[playerid] = 1;
case 1: DiceResult[playerid] = 2;
case 2: DiceResult[playerid] = 3;
case 3: DiceResult[playerid] = 4;
case 4: DiceResult[playerid] = 5;
case 5: DiceResult[playerid] = 6;
case 6: DiceResult[playerid] = 7;
case 7: DiceResult[playerid] = 8;}
if(PlayerBet[playerid] == 1 && DiceResult[playerid] == 1){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 2 && DiceResult[playerid] == 2){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 3 && DiceResult[playerid] == 3){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 4 && DiceResult[playerid] == 4){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 5 && DiceResult[playerid] == 5){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 6 && DiceResult[playerid] == 6){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 7 && DiceResult[playerid] == 2 || DiceResult[playerid] == 4 || DiceResult[playerid] == 6){WonX2[playerid] = true;} else{WonX2[playerid] = false;}
if(PlayerBet[playerid] == 8 && DiceResult[playerid] == 1 || DiceResult[playerid] == 3 || DiceResult[playerid] == 5){WonX2[playerid] = true;} else{WonX2[playerid] = false;}
if(WonX2[playerid] && !WonX6[playerid]){
format(SString,sizeof(SString),"[Casino] {00FF00}YOU WON $%s!",Comma(param[0]*2));
MSG(playerid,C_GOLD,SString);
DB[playerid][Money]=DB[playerid][Money]+param[0];
WonX2[playerid] = false;
WonX6[playerid] = false;}
if(!WonX2[playerid] && WonX6[playerid]){
format(SString,sizeof(SString),"[Casino] {00FF00}YOU WON $%s!",Comma(param[0]*6));
MSG(playerid,C_GOLD,SString);
DB[playerid][Money]=DB[playerid][Money]+param[0]*5;
WonX2[playerid] = false;
WonX6[playerid] = false;}
if(!WonX2[playerid] && !WonX6[playerid]){
format(SString,sizeof(SString),"[Casino] {FF0000}You didn't win this this time.",Comma(param[0]*6));
MSG(playerid,C_GOLD,SString);
DB[playerid][Money]=DB[playerid][Money]+param[0]*5;
WonX2[playerid] = false;
WonX6[playerid] = false;}
if(WonX2[playerid] && WonX6[playerid]){
MSG(playerid,C_GOLD,"[Casino] {FF0000}If you see this message contact the admins as soon as possible.");
WonX2[playerid] = false;
WonX6[playerid] = false;
return 1;}
#pragma dynamic 3000
switch(rand){
case 0: DiceResult[playerid] = 1;
case 1: DiceResult[playerid] = 2;
case 2: DiceResult[playerid] = 3;
case 3: DiceResult[playerid] = 4;
case 4: DiceResult[playerid] = 5;
case 5: DiceResult[playerid] = 6;
case 6: DiceResult[playerid] = 7;
case 7: DiceResult[playerid] = 8;}
DiceResult[playerid] = rand + 1;
if(PlayerBet[playerid] == 1 && DiceResult[playerid] == 1){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 2 && DiceResult[playerid] == 2){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 3 && DiceResult[playerid] == 3){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 4 && DiceResult[playerid] == 4){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 5 && DiceResult[playerid] == 5){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
if(PlayerBet[playerid] == 6 && DiceResult[playerid] == 6){WonX6[playerid] = true;} else{WonX6[playerid] = false;}
WonX6[playerid] = (PlayerBet[playerid] == DiceResult[playerid]);
Your code looks terrible!
"estimated max. usage: unknown, due to recursion" The warning is no problem at all. Just means the Compiler cannot tell what the max. size of the heap/stack is because some code runs in recursion. Recursion means if a function calls itself, all containing variables are initialized again, however the Compiler does not know how often this happens because it's decided run-time. I don't see a recursion in your code though. Is MiniString global? |
Your code looks terrible!
"estimated max. usage: unknown, due to recursion" The warning is no problem at all. Just means the Compiler cannot tell what the max. size of the heap/stack is because some code runs in recursion. Recursion means if a function calls itself, all containing variables are initialized again, however the Compiler does not know how often this happens because it's decided run-time. I don't see a recursion in your code though. Is MiniString global? |
As I said, it's not a problem that it shows that message when compiling unless your script doesn't run at all.
However you should put "new MiniString[X];" into your command (and other functions/callbacks where you use it). It will make it a tiny bit faster and it's commonly done that way. |
You earned your rep!
btw I tried to expand it by 10000 by now it shows it again xD how much should I expand? |
PHP код:
|
WonX6[playerid] = (PlayerBet[playerid] == DiceResult[playerid]) ? (true) : (false);