Код:
CMD:votesys(cmdid, playerid, params[])
{
new tool[16];
if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "You're not allowed to use this command");
if(isnull(params)) return SCM(playerid, COLOR_RED, ""COL_RED"USAGE:"COL_WHITE" /votesys [create/cancel]");
if(strcmp(tool, "create", true) == 0)
{
if(isnull(params)) return SCM(playerid, COLOR_RED, ""COL_RED"USAGE:"COL_WHITE" /votesys [create] [text]");
if(OnVote == 1) return SCM(playerid,COLOR_RED,"There is a vote already started");
new str[128];
OnVote = 1;
strcpy(Voting[Vote], params, 50);
format(str, sizeof(str), "%s has started a vote: %s", GetName(playerid), params);
SendClientMessageToAll(COLOR_GREEN, str);
SendClientMessageToAll(COLOR_GREEN, "Type /vote to make a vote.");
SetTimer("CancelVote",20000, 0); // 20 Seconds, You can increase it.
//if(GetPVarInt(playerid,"CMDVOTE") > GetTickCount()) return SCM(playerid,0xFF0000FF,"You have to wait 10 minutes to use the command again");
//SetPVarInt(playerid,"CMDVOTE",GetTickCount()+600000);
return 1;
}
else if(strcmp(tool, "cancel", true) == 0)
{
new str[128], res[50];
if(sscanf(params, "S()[50]", res)) return SCM(playerid, COLOR_RED, ""COL_RED"USAGE:"COL_WHITE" /makevote [cancel] [reason]");
if(OnVote == 0) return SCM(playerid, COLOR_RED, "There is no vote currently going on!");
if(!isnull(res))
format(str, sizeof(str), "Administrator %s has canceled the vote: %s", GetName(playerid), res);
else format(str, sizeof(str), "Administrator %s has canceled the vote", GetName(playerid));
SendClientMessageToAll(COLOR_RED, str);
OnVote = 0;
foreach(new i : Player) Voted[i] = -1;
Voting[VoteY] = 0;
Voting[VoteN] = 0;
return 1;
}
return 1;
}
CMD:vote(cmdid, playerid, params[])
{
if(Voted[playerid] != 1) return SCM(playerid, COLOR_RED, "You have already voted, You can't vote again!");
if(OnVote == 1)
{
new tool[16], str[124];
if(sscanf(params, "s[16]", tool)) return SCM(playerid, COLOR_GREY, ""COL_RED"USAGE:"COL_WHITE" /vote [Yes / No]");
if(strcmp(tool, "Yes", true) == 0)
{
Voted[playerid] = 1;
Voting[VoteY]++;
format(str, sizeof(str), "Vote: %s - Yes: %d No: %d", Voting[Vote], Voting[VoteY], Voting[VoteN]);
SCM(playerid, COLOR_YELLOW, str);
return 1;
}
else if(strcmp(tool, "No", true) == 0)
{
Voted[playerid] = 0;
Voting[VoteN]++;
format(str, sizeof(str), "Vote: %s | Yes: %d No: %d", Voting[Vote], Voting[VoteY], Voting[VoteN]);
SCM(playerid, COLOR_YELLOW, str);
return 1;
}
}
else SCM(playerid, COLOR_RED, "There is no vote currently.");
return 1;
}
Whats wrong with this problem? When I type /votesys create, it doesn't shows /vote [create] [text] error and when i type /votesys cancel, it goes with the create function
Duh, you never put anything inside the "tool" variable. And if you use strcmp with an empty variable it will also return 0 (i.e. it says that the strings match).