Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*============================================================================
- | |
- | RandomDude's VoteSlap System! |
- | |
- ==============================================================================*/
- #define FILTERSCRIPT
- #include <a_samp>
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- #define GREY 0xAFAFAFAA
- #define GREEN 0x33AA33AA
- #define YELLOW 0xFFFF00AA
- #define WHITE 0xFFFFFFAA
- #define LIGHTBLUE 0x33CCFFAA
- #define ORANGE 0xFF9900AA
- new Votes = 0;
- new Voted[MAX_PLAYERS];
- new VoteActive;
- new thingy;
- new VPlayers;
- new SlapName[24];
- new PlayerName[24];
- forward CountDownTimer(playerid);
- new Count;
- new Timer;
- new Text:TCountDown;
- new Text:Voteslap;
- new Text:Votecash;
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("FilterScript Made By RandomDude.");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- Voted[playerid] = 0;
- return 1;
- }
- public CountDownTimer(playerid)
- {
- new string[3];
- Count--;
- TextDrawDestroy(TCountDown);
- format(string,sizeof(string),"%d",Count);
- TCountDown = TextDrawCreate(300.0,300.0,string);
- TextDrawTextSize(TCountDown,0.7,3.0);
- TextDrawShowForAll(TCountDown);
- if(Count == 0)
- {
- KillTimer(Timer);
- KillTimer(thingy);
- TextDrawDestroy(TCountDown);
- TextDrawDestroy(Voteslap);
- Voted[playerid] = 0;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(voteslap,8,cmdtext);
- dcmd(votes,4,cmdtext);
- dcmd(stopvote,8,cmdtext);
- dcmd(votecash,8,cmdtext);
- dcmd(votec,5,cmdtext);
- return 0;
- }
- dcmd_stopvote(playerid,params[])
- {
- #pragma unused params
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,LIGHTBLUE,"You are not an admin!");
- TextDrawDestroy(TCountDown);
- TextDrawDestroy(Voteslap);
- TextDrawDestroy(Votecash);
- KillTimer(Timer);
- KillTimer(thingy);
- SendClientMessageToAll(0xFF0000FF,"An admin has stopped the vote process.");
- return 1;
- }
- dcmd_voteslap(playerid,params[])
- {
- new id,n[24],on[24],str2[128],string[3];
- new tmp[256], tmp2[256], Index,str[128];
- VPlayers = GetPlayersOnServer()/2+1;
- if(GetPlayersOnServer() <= 2)
- return SendClientMessage(playerid,GREY,"The minimum players required for this command to work are 3.");
- tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp);
- if(IsPlayerAdmin(id)) return SendClientMessage(playerid,0xFF0000FF,"You cannot try to voteslap an admin! -_-");
- if(VoteActive == 1) return SendClientMessage(playerid,0xFF0000FF,"There is already a Vote for something in proccess, please wait until it has finished.");
- GetPlayerName(playerid,n,24),GetPlayerName(id,on,24);
- Voted[playerid] = 1;
- SlapName = on;
- PlayerName = n;
- if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /voteslap [ID] [Reason]");
- if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID.");
- Votes = 1;
- VoteActive = 1;
- format(str2,sizeof(str2),"~r~Voteslap on ~w~%s. ~r~%d/%d",PlayerName,Votes,VPlayers);
- Voteslap = TextDrawCreate(50.0,300.0,str2);
- TextDrawLetterSize(Voteslap,0.5,2.5);
- TextDrawShowForAll(Voteslap);
- thingy = SetTimer("VoteFail",21000,false);
- Timer = SetTimerEx("CountDownTimer",1000,true,"i",playerid);
- format(str,sizeof(str),"%s has started a voteslap on %s. Reason: %s. To vote - /votes",n,on,params[2]);
- SendClientMessageToAll(0xFF0000FF,str);
- format(string,sizeof(string),"%d",Count);
- TCountDown = TextDrawCreate(300.0,300.0,string);
- Count = 21;
- return 1;
- }
- dcmd_votes(playerid,params[])
- {
- #pragma unused params
- new str[128],name[24],str2[128];
- GetPlayerName(playerid,name,24);
- if(VoteActive == 0) return SendClientMessage(playerid,GREY,"There is no active vote slap on right now.");
- if(Voted[playerid] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You have already voted!");
- KillTimer(thingy);
- thingy = SetTimer("VoteFail",21000,false);
- Votes++;
- Voted[playerid] = 1;
- format(str,sizeof(str),"%s has voted. %d/%d",name,Votes,VPlayers);
- SendClientMessageToAll(0xFF0000FF,str);
- TextDrawDestroy(Voteslap);
- format(str2,sizeof(str),"~r~Voteslap on ~w~%s. ~r~%d/%d",Votes,VPlayers);
- TextDrawCreate(50.0,300,str2);
- TextDrawLetterSize(Voteslap,0.5,2.5);
- TextDrawShowForAll(Voteslap);
- KillTimer(Timer);
- Timer = SetTimer("CountDownTimer",1000,true);
- Count = 21;
- if(Votes == VPlayers)
- {
- format(str,sizeof(str),"%s has been slapped. %d/%d votes.",Votes,Votes);
- SendClientMessageToAll(0xFF0000FF,str);
- TextDrawDestroy(Voteslap);
- KillTimer(thingy);
- VoteActive = 0;
- new Float:PPos[3];
- GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
- SetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]+4);
- return 1;
- }
- return 1;
- }
- //NEW VOTE SYSTEM to take away money from player
- dcmd_votecash(playerid,params[])
- {
- new id,n[24],on[24],str2[128],string[3];
- new tmp[256], tmp2[256], Index,str[128];
- VPlayers = GetPlayersOnServer()/2+1;
- if(GetPlayersOnServer() <= 2)
- return SendClientMessage(playerid,GREY,"The minimum players required for this command to work are 3.");
- tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp);
- if(IsPlayerAdmin(id)) return SendClientMessage(playerid,0xFF0000FF,"You cannot try to Votecash an admin! -_-");
- if(VoteActive == 1) return SendClientMessage(playerid,0xFF0000FF,"There is already a Vote for something in proccess, please wait until it has finished.");
- GetPlayerName(playerid,n,24),GetPlayerName(id,on,24);
- Voted[playerid] = 1;
- SlapName = on;
- PlayerName = n;
- if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /Votecash [ID] [Reason]");
- if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID.");
- Votes = 1;
- VoteActive = 1;
- format(str2,sizeof(str2),"~r~Votecash on ~w~%s. ~r~%d/%d",PlayerName,Votes,VPlayers);
- Votecash = TextDrawCreate(50.0,300.0,str2);
- TextDrawLetterSize(Votecash,0.5,2.5);
- TextDrawShowForAll(Votecash);
- thingy = SetTimer("VoteFail",21000,false);
- Timer = SetTimerEx("CountDownTimer",1000,true,"i",playerid);
- format(str,sizeof(str),"%s has started a Votecash on %s. Reason: %s. To vote - /votec",n,on,params[2]);
- SendClientMessageToAll(0xFF0000FF,str);
- format(string,sizeof(string),"%d",Count);
- TCountDown = TextDrawCreate(300.0,300.0,string);
- Count = 21;
- return 1;
- }
- dcmd_votec(playerid,params[])
- {
- #pragma unused params
- new str[128],name[24],str2[128];
- GetPlayerName(playerid,name,24);
- if(VoteActive == 0) return SendClientMessage(playerid,GREY,"There is no active vote cash on right now.");
- if(Voted[playerid] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You have already voted!");
- KillTimer(thingy);
- thingy = SetTimer("VoteFail",21000,false);
- Votes++;
- Voted[playerid] = 1;
- format(str,sizeof(str),"%s has voted. %d/%d",name,Votes,VPlayers);
- SendClientMessageToAll(0xFF0000FF,str);
- TextDrawDestroy(Votecash);
- format(str2,sizeof(str),"~r~Votecash on ~w~%s. ~r~%d/%d",Votes,VPlayers);
- TextDrawCreate(50.0,300,str2);
- TextDrawLetterSize(Votecash,0.5,2.5);
- TextDrawShowForAll(Votecash);
- KillTimer(Timer);
- Timer = SetTimer("CountDownTimer",1000,true);
- Count = 21;
- if(Votes == VPlayers)
- {
- format(str,sizeof(str),"%s has lost some cash :D. %d/%d votes.",Votes,Votes);
- SendClientMessageToAll(0xFF0000FF,str);
- TextDrawDestroy(Votecash);
- KillTimer(thingy);
- VoteActive = 0;
- GivePlayerMoney(playerid,-10000);
- return 1;
- }
- return 1;
- }
- forward VoteFail(playerid);
- public VoteFail(playerid)
- {
- Votes = 0;
- VoteActive = 0;
- Voted[playerid] = 0;
- SendClientMessageToAll(LIGHTBLUE,"There were not enough votes for an action to be taken.! :)");
- TextDrawDestroy(Voteslap);
- TextDrawDestroy(Votecash);
- return 1;
- }
- GetPlayersOnServer()
- {
- new count;
- for(new x=0; x< MAX_PLAYERS; x++)
- {
- if(IsPlayerConnected(x))
- {
- count++;
- }
- }
- return count;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement