Problem with warn-command!
#1

'Sup y'all?

Well, I'm makin' a warn-command, which kicks the player when he gets more than 3 warnings, but it doesn't work! When I warn myself, there's written: 98/3 warnings, and the player won't after 3 times get kicked...Okay, I get no errors, but I still am not sure what to do:

PHP код:
    #define MAX_WARNINGS 3 
PHP код:
CMD:warn(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 3)
    {
            new 
Target;
            new 
Reason[50];
           
// if(sscanf(params, "us[50]", Target)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /warn [playerid] [reason]");
            
if(!sscanf(params"us[50]"TargetReason))
            {
                
//if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
                
if(!IsPlayerConnected(Target))
                    return 
SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected!");
                if(
PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You can't perform this command on Admins that are higher than your level!");
                
PlayerInfo[Target][Warnings]++;
                new 
tname[MAX_PLAYER_NAME];
                
GetPlayerName(Target,tname,sizeof(tname));
                new 
pname[MAX_PLAYER_NAME];
                
GetPlayerName(playerid,pname,sizeof(pname));
                new 
MyString[256];
                new 
TargetString[256];
                
WarnLog(Target);
                
format(MyString,sizeof MyString"You have warned %s! (Reason: %s) (Warnings: %d/%d)"tnameReasonPlayerInfo[Target][Warnings],MAX_WARNINGS);
                
format(TargetString,sizeof TargetString"Administrator %s has given %s a warning! Reason: %s (Warnings: %d/%d)"pnametnameReason,PlayerInfo[Target][Warnings],MAX_WARNINGS);
                
SendClientMessage(TargetCOLOR_REDTargetString);
                
SendClientMessageToAll(COLOR_YELLOWMyString);
                if(
PlayerInfo[Target][Warnings] == MAX_WARNINGS)
                {
                    new 
kstring[256];
                    new 
name[MAX_PLAYER_NAME];
                    
GetPlayerName(Target,name,sizeof(name));
                    
format(kstring,sizeof(kstring),"Player %s (ID:%d) got kicked! (Reason: Maximum warnings)"nameTarget);
                    
SendClientMessageToAll(COLOR_RED,kstring);
                    
PlayerInfo[Target][Warnings] = 0;
                    
WarnKick(Target);
                    
Kick(Target);
                }
            }
    }
    else return 
SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 3 to perform this command!");
    return 
1;

PHP код:
            stock WarnKick(Target)
            {
                    new 
File:Log fopen(warnPATHio_append);
                 new    
logData[128];
                 new 
name[MAX_PLAYER_NAME];
                 
GetPlayerName(Target,name,sizeof(name));
                new 
fTime[6];
                
getdate(fTime[0], fTime[1], fTime[2]);
                
gettime(fTime[3], fTime[4], fTime[5]);
                
format(logDatasizeof logData"[%02d/%02d/%04d || %02d:%02d:%02d]%s got kicked for reaching maximum warnings!\r\n"fTime[2], fTime[1], fTime[0], fTime[3], fTime[4], fTime[5], name);
                
fwrite(LoglogData);
                
fclose(Log);
                return 
1;
            }
            
            
stock WarnLog(Target)
            {
                  new 
File:Log fopen(warnPATHio_append);
                 new    
logData[128];
                 new 
name[MAX_PLAYER_NAME];
                 
GetPlayerName(Target,name,sizeof(name));
                new 
fTime[6];
                
getdate(fTime[0], fTime[1], fTime[2]);
                
gettime(fTime[3], fTime[4], fTime[5]);
                
format(logDatasizeof logData"[%02d/%02d/%04d || %02d:%02d:%02d]%s got warned!\r\n"fTime[2], fTime[1], fTime[0], fTime[3], fTime[4], fTime[5], name);
                
fwrite(LoglogData);
                
fclose(Log);
                return 
1;
            } 
Reply


Messages In This Thread
Problem with warn-command! - by Twisted_Insane - 23.02.2012, 20:34
Re: Problem with warn-command! - by Tanush123 - 23.02.2012, 20:44
Re: Problem with warn-command! - by Twisted_Insane - 24.02.2012, 07:52
Re: Problem with warn-command! - by Tanush123 - 25.02.2012, 20:49
Re: Problem with warn-command! - by Konstantinos - 25.02.2012, 21:53
Re: Problem with warn-command! - by HighPitchedVoice - 25.02.2012, 21:58
Re: Problem with warn-command! - by Tanush123 - 26.02.2012, 00:50

Forum Jump:


Users browsing this thread: 1 Guest(s)