/warn command problem
#1

PHP код:
    if(strcmp(cmd"/warn"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"Използвай: /warn [Playerid/PartOfName] [reason]");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            if (
PlayerInfo[playerid][pAdmin] >= 1)
            {
                if(
IsPlayerConnected(giveplayerid))
                {
                    if(
giveplayerid != INVALID_PLAYER_ID)
                    {
                        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                        new 
length strlen(cmdtext);
                        while ((
idx length) && (cmdtext[idx] <= ' '))
                        {
                            
idx++;
                        }
                        new 
offset idx;
                        new 
result[256];
                        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                        {
                            
result[idx offset] = cmdtext[idx];
                            
idx++;
                        }
                        
result[idx offset] = EOS;
                        if(!
strlen(result))
                        {
                            
SendClientMessage(playeridCOLOR_WHITE"Използвай: /warn [Playerid/PartOfName] [reason]");
                            return 
1;
                        }
                        
PlayerInfo[giveplayerid][pWarns] += 0;
                        if(
PlayerInfo[giveplayerid][pWarns] == 5)
                        {
                            
format(stringsizeof(string), "%s кикна %s, защото той събра 5 предупреждения. Причина: %s"PlayerName(playerid), giveplayer, (result));
                            
SendClientMessageToAll(COLOR_REDstring);
                            
Kick(playerid);
                            return 
1;
                        }
                        if(
PlayerInfo[giveplayerid][pWarns] += 1)
                        
format(stringsizeof(string), "%s was warned by %s [%d/5]. [Reason: %s]"giveplayerPlayerName(playerid), PlayerInfo[giveplayerid][pWarns], (result));
                        
SendClientMessageToAll(COLOR_REDstring);
                        
format(stringsizeof(string), "%s ти сложи предупреждение. Причина: %s"PlayerName(playerid), (result));
                        
SendClientMessage(giveplayeridCOLOR_REDstring);
                        return 
1;
                    }
                }
            }
            else
            {
                
format(stringsizeof(string), "   Посоченото ID не е в сървъра.");
                
SendClientMessage(playeridCOLOR_GRAD1string);
            }
        }
        return 
1;
    } 
When you collect 5 warns not Ban
Reply
#2

Replace
pawn Код:
PlayerInfo[giveplayerid][pWarns] += 0;
With
pawn Код:
PlayerInfo[giveplayerid][pWarns]++;
And remove
pawn Код:
if(PlayerInfo[giveplayerid][pWarns] += 1)
Reply
#3

Код:
    if(strcmp(cmd, "/warn", true) == 0) 
    { 
        if(IsPlayerConnected(playerid)) 
        { 
            tmp = strtok(cmdtext, idx); 
            if(!strlen(tmp)) 
            { 
                SendClientMessage(playerid, COLOR_WHITE, "Използвай: /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)); 
                        new length = strlen(cmdtext); 
                        while ((idx < length) && (cmdtext[idx] <= ' ')) 
                        { 
                            idx++; 
                        } 
                        new offset = idx; 
                        new result[256]; 
                        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, "Използвай: /warn [Playerid/PartOfName] [reason]"); 
                            return 1; 
                        } 
                        PlayerInfo[giveplayerid][pWarns]++;
                        if(PlayerInfo[giveplayerid][pWarns] == 5) 
                        { 
                            format(string, sizeof(string), "%s кикна %s, защото той събра 5 предупреждения. Причина: %s", PlayerName(playerid), giveplayer, (result)); 
                            SendClientMessageToAll(COLOR_RED, string); 
                            Kick(playerid); 
                            return 1; 
                        } 
                        if(PlayerInfo[giveplayerid][pWarns] += 1) 
                        format(string, sizeof(string), "%s was warned by %s [%d/5]. [Reason: %s]", giveplayer, PlayerName(playerid), PlayerInfo[giveplayerid][pWarns], (result)); 
                        SendClientMessageToAll(COLOR_RED, string); 
                        format(string, sizeof(string), "%s ти сложи предупреждение. Причина: %s", PlayerName(playerid), (result)); 
                        SendClientMessage(giveplayerid, COLOR_RED, string); 
                        return 1; 
                    } 
                } 
            } 
            else 
            { 
                format(string, sizeof(string), "   Посоченото ID не е в сървъра."); 
                SendClientMessage(playerid, COLOR_GRAD1, string); 
            } 
        } 
        return 1; 
    }
By the way, How many warns you want to ban the player?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)