Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Credits:
- ZCMD > Command System.
- Brandon_More (GiGi) > Scripter.
- Woot > SendClientError - SCP - SendMessageToPlayer functions.
- Slice (I Think) > Number controllers.
- */
- #include <a_samp>
- #include <zcmd>
- #define ALTCOMMAND:%1->%2; \
- COMMAND:%1(playerid, params[]) \
- return cmd_%2(playerid, params);
- new iStr[ 164 ]; // Global String
- /*
- Colo(u)r Name Colo(u)r Value
- */
- #define COLOR_LIGHTGREY 0xCCCCCCFF
- #define COLOR_RED 0xCC3300FF
- /*
- Define Name Define Value
- */
- #define CANT_USE_CMD "You are not allowed to use this command!"
- /* Woot stuff */
- SendClientError(playerid, errormessage[]) {
- new _error[256];
- format(_error, 256, "{ffa10d}[Error]: {d58609}%s", errormessage);
- if(IsPlayerConnected(playerid)) SendClientMessage(playerid, COLOR_RED, _error);
- return 1;
- }
- stock SCP(_id, _param[], _command[] = "") {
- format(iStr, sizeof(iStr), "{6a696a}[Command]: /%s {9c9a9c}%s", _command, _param);
- return SendMessageToPlayer(_id, COLOR_LIGHTGREY, iStr, 128);
- }
- stock PlayerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
- stock SendMessageToPlayer(playerid, color, text[], len = 132) {
- new
- text2[ 256 ],
- maxstring = 384;
- if(strlen(text) > len)
- {
- strmid(text2, text, len, maxstring);
- strdel(text, len, maxstring);
- strins(text, " ..", len, maxstring);
- strins(text2, ".. ", 0, maxstring);
- SendClientMessage(playerid, color, text);
- SendClientMessage(playerid, color, text2);
- return 1;
- }
- else return SendClientMessage(playerid, color, text);
- }
- /* Emd woot stuff */
- new
- lotteryNum,
- lotteryPrize[ 40 ],
- lotteryPrice,
- lotteryRange;
- public OnFilterScriptInit() {
- return 1;
- }
- COMMAND:startlot(playerid, params[]){
- if(!IsPlayerAdmin(playerid))
- return SendClientError(playerid,CANT_USE_CMD);
- new iPrice,
- iPrize[ 40 ],
- iNumber,
- iRange;
- if( sscanf ( params, "ddsd", iNumber, iPrice, iPrize, iRange))
- return SCP(playerid, "[Ticket number][Price of ticket][prize][Range]");
- if(iPrice > 500000 || iPrice < 2500)
- return SendClientError(playerid,"Price of the ticket has to be higher than 2,500 and lower than 500,000");
- if(iRange < 1 || iRange > 500 || iNumber > 500 || iNumber < 1)
- return SendClientError(playerid, "Lottery range is too high - Maximum of 500");
- lotteryPrize = iPrize;
- lotteryPrice = iPrice;
- lotteryNum = iNumber;
- lotteryRange = iRange;
- format(iStr, sizeof(iStr), "{7b94a1}[Lottery] {b5cdda} Prize: %s | Ticket Price: $%s", lotteryPrize, number_format(lotteryPrice));
- SendClientMessage(playerid,COLOR_LIGHTGREY,iStr);
- format(iStr, sizeof(iStr), "{7b94a1}[Lottery] {b5cdda} Use /lot <1-%d> in order to get a chance to win.", iRange);
- SendClientMessage(playerid,COLOR_LIGHTGREY,iStr);
- return 1;
- }
- COMMAND:changelot(playerid, params[]) {
- if(!IsPlayerAdmin(playerid)) return SendClientError(playerid,CANT_USE_CMD);
- new iNumber;
- if( sscanf ( params, "d", iNumber))
- return SCP(playerid, "[Ticket number]");
- if(lotteryNum < 1)
- return SendClientError(playerid, "There isn't a lottery on..");
- lotteryNum = iNumber;
- SendClientMessageToAll(COLOR_LIGHTGREY,"{7b94a1}[Lottery] {b5cdda} Warning an Administrator has changed the lottery number.");
- return 1;
- }
- COMMAND:stoplot(playerid, params[]) {
- if(!IsPlayerAdmin(playerid)) return SendClientError(playerid,CANT_USE_CMD);
- if(lotteryNum < 1)
- return SendClientError(playerid, "There isn't a lottery on..");
- lotteryNum = 0; lotteryPrice = 0; lotteryRange = 0;
- SendClientMessageToAll(COLOR_LIGHTGREY,"An Administrator has stopped the current lottery");
- return 1;
- }
- // During Testing... :)
- COMMAND:givemecash(playerid, params[]) {
- GivePlayerMoney(playerid, lotteryPrice);
- return 1;
- }
- COMMAND:unfreeze(playerid, params[]) {
- TogglePlayerControllable(playerid, true);
- return 1;
- }
- //Finish Testing
- COMMAND:lot(playerid, params[]) {
- if(!IsPlayerConnected(playerid)) return SendClientError(playerid,CANT_USE_CMD);
- new iNumber;
- new kesh = GetPlayerMoney(playerid);
- if( sscanf ( params, "d", iNumber)) return SCP(playerid, "[Ticket number]");
- if(lotteryNum < 1)
- return SendClientError(playerid, "There isn't a lottery currently on");
- if(iNumber > lotteryRange)
- return SendClientError(playerid, "You have exceeded the lottery range");
- if(kesh < lotteryPrice)
- return SendClientError(playerid, "Not enough kesh");
- GivePlayerMoney(playerid, -lotteryPrice);
- if(iNumber != lotteryNum) {
- SendClientMessage(playerid,COLOR_LIGHTGREY,"{7b94a1}[Lottery]{b5cdda} Thank you for your participation! Unfortunately, you haven't won anything.");
- }
- else {
- format(iStr, sizeof(iStr), "{7b94a1}[Lottery] {b5cdda} %s has won the lottery with #%d - PRIZE: %s!!", PlayerName(playerid), lotteryNum, lotteryPrize);
- SendClientMessage(playerid,COLOR_LIGHTGREY,iStr);
- lotteryNum = 0; lotteryPrice = 0; lotteryRange = 0;
- SendClientMessage(playerid, COLOR_LIGHTGREY,"You have been frozen, untill you have recieved your reward from an Administrator");
- TogglePlayerControllable(playerid, false);
- }
- return 1;
- }
- // number_format function by Slice i think
- stock number_format( num )
- {
- new stri[16], stro[16], i, v, p, d, l, n = num < 0;
- format( stri, sizeof( stri ), "%d", num * ( n ? -1 : 1 ) );
- l = strlen( stri ) - 1;
- d = ( l - ( l % 3 ) ) / 3;
- l = l + 1;
- i = l + d;
- p = l;
- while ( i >= 0 )
- {
- v = l + d - i;
- if ( v && !( v % 4 ) )
- stro[i + n] = ',';
- else
- stro[i + n] = stri[p--];
- i--;
- }
- stro[0] = n ? '-' : stro[0];
- return stro;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement