28.03.2016, 15:52
This command is not detecting days,its always banning the player permanently
Код:
if(!strcmp(cmd,"/ban",true)) { if(PlayerInfo[playerid][pAdmin] <= 3) return SCM(playerid,COLOR_YELLOW2,"Error: Shoma Admin Nisti"); new Fullname[256]; Fullname = strtok(cmdtext,idx); if(!strlen(Fullname)) return SCM(playerid,COL_SYN,"Syntax: /ban <FullName> <Days(1-60 , 0= Perementaly Ban)> <UseIP(1=Yes 0=No)> <Reason>"); tmp = strtok(cmdtext,idx); if(!strlen(tmp)) return SCM(playerid,COL_SYN,"Syntax: /ban <FullName> <Days(1-60 , 0= Perementaly Ban)> <UseIP(1=Yes 0=No)> <Reason>"); new days = strval(tmp); if(days < 0 || days > 60) return SCM(playerid,COLOR_ARIAIE,"Type a day between 1 and 60."); tmp = strtok(cmdtext,idx); if(!strlen(tmp)) return SCM(playerid, COL_SYN, "Syntax: /ban <FullName> <Days(1-60 , 0= Perementaly Ban)> <UseIP(1=Yes 0=No)> <Reason>"); new UseIP = strval(tmp); if(UseIP != 1 && UseIP != 0) return SCM(playerid, COLOR_ARIAIE, "UseIP must be 0 or 1"); tmp = strtokEx(cmdtext,idx); if(!strlen(tmp)) return SCM(playerid,COL_SYN,"Syntax: /ban <FullName> <Days(1-60 , 0= Perementaly Ban)> <UseIP(1=Yes 0=No)> <Reason>"); BanPlayer(playerid, Fullname, days, tmp, UseIP); return 1; }
Код:
BanPlayer(playerid, taraf[], days, reason[], UseIP = 1) { new Name[MAX_PLAYER_NAME]; if(IsPlayerConnected(playerid)) format(Name, MAX_PLAYER_NAME, PINFO[playerid][pName]); else format(Name, MAX_PLAYER_NAME, "AdmBot"); new tarafid = ReturnUserEx(taraf); if(IsPlayerConnected(tarafid)) { if(days != 0) PINFO[tarafid][pBanned] = 1; if(days >= 0) PINFO[tarafid][pBanned] = 2; PINFO[tarafid][pBanDays] = days; new bantime[200]; new sal, mah, rooz, saat, daqiqe, sanie; getdate(sal, mah, rooz); gettime(saat, daqiqe, sanie); sal -= 2000; format(bantime, 200, "%02d/%02d/%02d %02d:%02d:%02d", sal, mah, rooz, saat, daqiqe, sanie); strmid(PlayerInfo[tarafid][pBanTime],bantime,0,strlen(bantime),80); strmid(PlayerInfo[tarafid][pBannedBy],Name,0,strlen(Name),40); strmid(PlayerInfo[tarafid][pBanReason],reason,0,strlen(reason),128); SaveKonVal(tarafid, "pBanned", PINFO[tarafid][pBanned]); SaveKonVal(tarafid, "pBanDays", PINFO[tarafid][pBanDays]); SaveKonStr(tarafid, "pBanTime", bantime); SaveKonStr(tarafid, "pBannedBy", Name); SaveKonStr(tarafid, "pBanReason", reason); if(UseIP == 1) { if(days == 0) { new query[256]; format(query, 256, "INSERT INTO `banneds` (`IP`,`BannedBy`,`BannedReason`,`bannedtime`)VALUES ('%s','%s','%s','%s')",PINFO[tarafid][pIp],Name,reason,bantime); mysql_tquery(handle, query, "SendQuery", ""); } } new stringt[300]; if(days != 0) format(stringt, 300, "AdmCmd: %s has been banned by admin %s for %i days reason: %s",taraf,Name,days,reason); if(days == 0) format(stringt, 300, "AdmCmd: %s has been permanentaly banned by admin %s reason: %s",taraf,Name,reason); KickWithMessage(tarafid, COLOR_LIGHTRED, "You have been banned."); SendClientMessageToAll(COLOR_LIGHTRED, stringt); } else { new query[256]; format(query, 256, "SELECT * FROM `users` WHERE pName='%s'",taraf); mysql_tquery(handle, query, "BanOfflinePlayer", "isisi", playerid, taraf, days, reason, UseIP); } return 1; }