Introduction
I'm bored so i make this tutorial to help you making a TimeVoter.
Scripting
So guys let's begin.
We add this in begin of script
PHP Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
Now after we add the includes, lets make the CMD
PHP Code:
CMD:vote(playerid,params[])
{ //Opening bracket
return 1; //Send to server that the command was successfull
} //Closing bracket
Now lets make the variables
PHP Code:
CMD:vote(playerid,params[])
{
new start;//the variable to see if he has typed /vote start
new day;//the times of voting with /vote day
return 1;
}
Now lets make when he type /vote he get an USAGE message :
PHP Code:
CMD:vote(playerid,params[])
{
new start;//the variable to see if he has typed /vote start
new day;//the times of voting with /vote day
return 1;
if(sscanf(params, "d", start)) return 1; SendClientMessage(playerid, -1, "USAGE : /Vote [Start - Stop - Day]");//error message
return 1;
}
Now lets make when he type /vote start he get a message that he tell him that the vote is started :
PHP Code:
CMD:vote(playerid,params[])
{
new start;//the variable to see if he has typed /vote start
new day;//the times of voting with /vote day
return 1;
if(sscanf(params, "d", start)) return 1; SendClientMessage(playerid, -1, "USAGE : /Vote [Start - Stop - Day]");//error message
SendClientMessage(playerid, -1, "The Vote Has Been Started");
SendClientMessageToAll(-1, "*************TimeVoter***************");
SendClientMessageToAll(-1, "* The Vote Has Been Started *");
SendClientMessageToAll(-1, "* Use /vote day To Vote *");
SendClientMessageToAll(-1, "*************************************");
return 1;
}
Now lets send him a message when he type /vote day :
PHP Code:
CMD:vote(playerid,params[])
{
new start;//the variable to see if he has typed /vote start
new day;//the times of voting with /vote day
return 1;
if(sscanf(params, "d", start)) return 1; SendClientMessage(playerid, -1, "USAGE : /Vote [Start - Stop - Day]");//error message
SendClientMessage(playerid, -1, "The Vote Has Been Started");
SendClientMessageToAll(-1, "*************TimeVoter***************");
SendClientMessageToAll(-1, "* The Vote Has Been Started *");
SendClientMessageToAll(-1, "* Use /vote day To Vote *");
SendClientMessageToAll(-1, "*************************************");
if(sscanf(params, "s", day)) //if he type /vote day
{ //opening bracket
day++;//we add +1 to variable day (mean +vote)
return 1;
}
Now we will add a message when the target is get in (when 5 players vote)
PHP Code:
CMD:vote(playerid,params[])
{
new start;//the variable to see if he has typed /vote start
new day;//the times of voting with /vote day
return 1;
if(sscanf(params, "d", start)) return 1; SendClientMessage(playerid, -1, "USAGE : /Vote [Start - Stop - Day]");//error message
SendClientMessage(playerid, -1, "The Vote Has Been Started");
SendClientMessageToAll(-1, "*************TimeVoter***************");
SendClientMessageToAll(-1, "* The Vote Has Been Started *");
SendClientMessageToAll(-1, "* Use /vote day To Vote *");
SendClientMessageToAll(-1, "*************************************");
if(sscanf(params, "s", day)) //if he type /vote day
{ //opening bracket
day++;//we add +1 to variable day (mean +vote)
if(day > 5) //if the target get in we set the time to 6 am
{
SendClientMessageToAll(-1, "*************TimeVoter***************");
SendClientMessageToAll(-1, "*******The Vote Has Been Passed******");
SendClientMessageToAll(-1, "***The Server Time Changed To Day****");
SendClientMessageToAll(-1, "*************************************");
SetWorldTime(6);
return 1;
}
if(day < 5) //if he don't get in we don't change anything
{
SendClientMessageToAll(-1, "*************TimeVoter***************");
SendClientMessageToAll(-1, "*********The Vote Has Failed*********");
SendClientMessageToAll(-1, "*******Server Time Not Changed*******");
SendClientMessageToAll(-1, "*************************************");
return 1;
}
}
return 1;
}
Hope you learned it !
Credits
- Me : Making Script And Tutorial
- Zeex : ZCMD
- The Owner Of SSCANF : sscanf
- Mongi : Some help
If There Is Bugs Or Errors Report It Here.