Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock StartLottery(range_min, range_max, lot_number, lot_fee, const lot_prize[64 + 1])
- {
- if(lottoData[isActive])
- return 0;
- lottoData[isActive] = true, lottoData[rangeMin] = range_min, lottoData[rangeMax] = range_max,
- lottoData[lottoNumber] = lot_number, lottoData[entryFee] = lot_fee;
- strcat((lottoData[winPrize] = '\0', lottoData[winPrize]), lot_prize, (64 + 1));
- SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
- new string[MAX_STRING];
- format(string, sizeof(string), "{b0c4de}Prize:{4169e1} %s", lottoData[winPrize]);
- SendClientMessageToAll(-1, string);
- format(string, sizeof(string), "{b0c4de}Ticket Price:{4169e1} $%s",
- number_format(lottoData[entryFee]));
- SendClientMessageToAll(-1, string);
- format(string, sizeof(string), "{b0c4de}Use{4169e1} /lot <%s-%s>{b0c4de} in order to get a chance to win.",
- number_format(lottoData[rangeMin]), number_format(lottoData[rangeMax]));
- SendClientMessageToAll(-1, string);
- SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
- UpdateLotteryTextDraw();
- TextDrawShowForAll(lottoTD);
- return 1;
- }
- stock StopLottery(playerid)
- {
- if(!lottoData[isActive])
- return 0;
- SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
- new string[MAX_STRING];
- format(string, sizeof(string), "{4169e1}%s{b0c4de} has stopped the ongoing lottery. The winning ticket was {4169e1}#%s",
- RPName(playerid), number_format(lottoData[lottoNumber]));
- SendClientMessageToAll(-1, string);
- SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
- lottoData[isActive] = false, lottoData[rangeMin] = 0, lottoData[rangeMax] = 0,
- lottoData[lottoNumber] = 0, lottoData[lottoEntries] = 0, lottoData[entryFee] = 0, lottoData[winPrize] = '\0';
- TextDrawHideForAll(lottoTD);
- return 1;
- }
- // --
- // Lottery commands
- COMMAND:startlottery(playerid, params[])
- {
- if(GetAdminLevel(playerid) < 10)
- return SendClientError(playerid, CANT_USE_CMD);
- new
- range_min,
- range_max,
- lot_number,
- lot_fee,
- lot_prize[64 + 1];
- if(sscanf(params, "dddds[65]", range_min, range_max, lot_number, lot_fee, lot_prize)) return SCP(playerid, "[Minimum] [Maximum] [WinningTicket] [Fee] [Prize(64 characters)]");
- else
- StartLottery(range_min, range_max, lot_number, lot_fee, lot_prize);
- if(range_min > range_max)
- return SendClientError(playerid, "Minimum range can't be higher than maximum range!");
- if(range_min > lot_number || lot_number > range_max)
- return SendClientError(playerid, "Lottery number can't be higher or lower than minimum or maximum range.");
- if(!StartLottery(range_min, range_max, lot_number, lot_fee, lot_prize))
- return SendClientError(playerid, "There is already an ongoing lottery!");
- return 1;
- }
Add Comment
Please, Sign In to add comment