Lottery issue - an error with an IF sentence + indicators +REP
#2

Try this:
pawn Код:
PHP Code:
new iLottoNumber;
new iAmountL;
new iTickets;
new iPrize[MAX_STRING];
new bool:IsLottoStarted=false;
new lString[MAX_STRING];
new lString1[MAX_STRING];
new lString2[MAX_STRING];
new lString3[MAX_STRING];
new lString8[MAX_STRING];
new lString9[MAX_STRING];
new iSpent;
COMMAND:startlotto(playerid, params[])
{

    if(GetAdminLevel(playerid) < 10) return SendClientError(playerid, CANT_USE_CMD);
    if( sscanf ( params, "iiii", iLottoNumber, iAmountL, iTickets, iPrize))  return SCP(playerid, "[WinningTicket] [TicketPrice] [TicketRange] [Reward]");
    if(IsLottoStarted == true) return SendClientError(playerid, "There's an ongoing lottery!");
 else
 {
    IsLottoStarted=true;
    format(lString, sizeof(lString), "{0520f2}================== [ {5ba8de} LOTTERY {0520f2} ] ==================");
    format(lString1, sizeof(lString1), "{5ba8de}Admin %s has started lottery. The entry fee is: %d$. The tickets range from 0 - %d.", RPName(playerid), iAmountL, iTickets);
    format(lString2, sizeof(lString2), "{5ba8de}The winner will receive %s as a reward. Goodluck and Have fun!", iPrize);
    format(lString3, sizeof(lString3), "{0520f2}================== [ {5ba8de} LOTTERY {0520f2} ] ==================");
    SendClientMessageToAll(COLOR_WHITE, lString);
    SendClientMessageToAll(COLOR_WHITE, lString1);
    SendClientMessageToAll(COLOR_WHITE, lString2);
    SendClientMessageToAll(COLOR_WHITE, lString3);

    }
     
    return 1;
}
new lString10[MAX_STRING];
new lString11[MAX_STRING];
new loseSTRING11[MAX_STRING];
COMMAND:lot(playerid, params[])
{
    new iGuess;
    if(IsLottoStarted == false) return SendClientError(playerid, "There aren't any ongoing lotteries!");
    if( sscanf ( params, "i", iGuess )) return SCP(playerid, "[Ticket Number]");
 if(iAmountL>HandMoney(playerid))
 {
 SendClientMSG(playerid, COLOR_RED, "{a40000}[ {e80b0b}Error {a40000}]{e83535} You do not have enough money in order to participate in this lottery");
 return 1;
 }
    if(iGuess == iLottoNumber )
    {
        iSpent = iAmountL + iSpent;
        format(lString10, sizeof(lString10), "{0520f2}================== [ {5ba8de}LOTTERY {0520f2} ] ==================");
        format(lString8, sizeof(lString8), "{5ba8de}%s has won the lottery with the number: %d! Prize: %s", RPName(playerid), iLottoNumber, iPrize);
        format(lString9, sizeof(lString9), "{5ba8de}In the lottery, players spent %i$! That's impressive!", iSpent);
        format(lString11, sizeof(lString11), "{0520f2}================== [ {5ba8de} LOTTERY {0520f2} ] ==================");
        SendClientMessageToAll(COLOR_WHITE, lString8);
        SendClientMessageToAll(COLOR_WHITE, lString9);
        SendClientMessageToAll(COLOR_WHITE, lString10);
        SendClientMessageToAll(COLOR_WHITE, lString11);
        IsLottoStarted=false;
        iLottoNumber = 0;
        iAmountL = 0;
        iSpent = 0;
        iTickets = 0;
        GivePlayerMoneyEx(playerid, -iAmountL);
     }
     else
    {

    iSpent = iAmountL + iSpent;
    format(loseSTRING11, sizeof(loseSTRING11), "{0520f2}[Lottery] {5ba8de} Sorry! You did not guess the number correctly. Good luck in your next attempt!", iAmountL);
        SendClientMessageToAll(COLOR_WHITE, loseSTRING11);
        GivePlayerMoneyEx(playerid, -iAmountL);
    }

     
    return 1;
}
new lendString[MAX_STRING];
new lendString2[MAX_STRING];
new lendString3[MAX_STRING];
new lendString4[MAX_STRING];


COMMAND:stoplotto(playerid, params[])
{
        if(IsLottoStarted == true)
        {
        IsLottoStarted = false;
         format(lendString3, sizeof(lendString3), "{0520f2}================== [ {5ba8de}LOTTERY{0520f2} ] ==================");
        format(lendString2, sizeof(lendString2), "{5ba8de}Admin %s has stopped the lottery. The winning ticket was %d!.  ", RPName(playerid), iLottoNumber);
        format(lendString, sizeof(lendString), "{5ba8de}In the lottery, players spent %i$! That's impressive!", iSpent);
        format(lendString4, sizeof(lendString4), "{0520f2}================== [ {5ba8de}LOTTERY{0520f2} ] ==================");
        SendClientMessageToAll(COLOR_WHITE, lendString3);
        SendClientMessageToAll(COLOR_WHITE, lendString2);
        SendClientMessageToAll(COLOR_WHITE, lendString);
        SendClientMessageToAll(COLOR_WHITE, lendString4);
        iLottoNumber = 0;
        iAmountL = 0;
        iSpent = 0;
        iTickets = 0;
        }
        return -1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)