03.08.2013, 22:10
Hello, I got a question which I can't solve myself, been busy trying to solve it for over 3 hours but i'm not a expert in scripting
The /warn command should give 3 warnings and then ban at the 3rd warning, problem is it already bans at the 2nd warning, how to solve it?
The /warn command should give 3 warnings and then ban at the 3rd warning, problem is it already bans at the 2nd warning, how to solve it?
Код:
if(strcmp(cmd, "/warn", true) == 0) { if(IsPlayerConnected(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /warn [playerid/PartOfName] [reason]"); return 1; } giveplayerid = ReturnUser(tmp); if(PlayerInfo[playerid][pAdmin] >= 1) { if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[96]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /warn [playerid/PartOfName] [reason]"); return 1; } new logstring[256]; new IP[16]; new year, month, day; getdate(year, month, day); if(UseAdmCmdTimer[playerid] > 2) { GetPlayerIp(playerid, IP, sizeof(IP)); format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Key: %s Reason: Spam.", IP, day, month, year,sendername,PlayerInfo[playerid][pKey]); BanLog(logstring); format(string, sizeof(string), "{FF0000}Server action{FF0000}: %s was banned, reason: Spam.", RemoveUnderScore(playerid)); SendClientMessageToAll(COLOR_RED, string); PlayerInfo[playerid][pBand] = 3; PlayerInfo[playerid][pPermBand] = 1; BanEx(playerid, "Banned By: Autoban Reason: Spam"); return 1; } if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin]) { format(string, sizeof(string), "{FF0000}Server action{FF0000}: %s was slapped, reason: Attempting to slap a higher admin.", RemoveUnderScore(playerid)); ABroadCast(COLOR_RED, string, 1); PlayerInfo[playerid][pWarns] += 1; if(PlayerInfo[playerid][pWarns] >= 3) { GetPlayerIp(giveplayerid, IP, sizeof(IP)); format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Key: %s Banned by: Autoban Reason: Attempting to warn a higher admin (3 Warnings).", IP, day, month, year,giveplayer,PlayerInfo[giveplayerid][pKey]); BanLog(logstring); format(string, sizeof(string), "{FF0000}Server action{FF0000}: %s was banned (3 Warnings), reason: Attempting to warn a higher admin", RPN(giveplayerid)); SendClientMessageToAll(COLOR_RED, string); PlayerInfo[giveplayerid][pBand] = 3; BanEx(giveplayerid, "Banned By: Autoban Reason: Had 3 Warnings"); return 1; } return 1; } PlayerInfo[giveplayerid][pWarns] += 1; if(PlayerInfo[giveplayerid][pWarns] >= 3) { GetPlayerIp(giveplayerid, IP, sizeof(IP)); format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Key: %s Banned by: %s Reason: %s (3 Warnings).", IP, day, month, year,giveplayer,PlayerInfo[giveplayerid][pKey],sendername, (result)); BanLog(logstring); format(string, sizeof(string), "{FF0000}Server action{FF0000}: %s was banned by %s (3 Warnings), reason: %s", RPN(giveplayerid), RemoveUnderScore(playerid), (result)); SendClientMessageToAll(COLOR_RED, string); PlayerInfo[giveplayerid][pBand] = 3; BanEx(giveplayerid, "Banned By: Autoban Reason: Had 3 Warnings"); return 1; } format(string, sizeof(string), "{FF0000}Server action{FF0000}: You warned %s, reason: %s", RPN(giveplayerid), (result)); SendClientMessage(playerid, COLOR_RED, string); format(string, sizeof(string), "{FF0000}Server action{FF0000}: You were warned by an Admin %s, reason: %s", RemoveUnderScore(playerid), (result)); SendClientMessage(giveplayerid, COLOR_RED, string); UseAdmCmdTimer[playerid]++; SetTimerEx("UseAdmCmd",3*1000,0,"i",playerid); //3 seconds return 1; } } else { format(string, sizeof(string), " %d is not an active player.", giveplayerid); SendClientMessage(playerid, COLOR_GRAD1, string); } } else { SendClientMessage(playerid, COLOR_GRAD2, " You are not authorized to use that command !"); } } return 1; }