SA-MP Forums Archive
Need Help {+Rep} - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need Help {+Rep} (/showthread.php?tid=327211)



Need Help {+Rep} - [GF]Logic - 20.03.2012

Quote:

CMD:kick(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 2)
{
new id, string[128], giveplayerid, reason[64], name[MAX_PLAYER_NAME], pname[MAX_PLAYER_NAME];
if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");

if(IsPlayerConnected(giveplayerid))
{
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(id,pname,sizeof(pname));
if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= 2 || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid)
{
format(string, sizeof(string), "AdmCmd: %s has been auto-kicked, reason: Trying to /kick a higher admin.", GetPlayerNameEx(playerid));
ABroadCast(COLOR_YELLOW,string, (PlayerInfo[playerid][pAdmin] == 1) ? (1) : (2));
Kick(playerid);
return 1;
}
else
{
new year, month,day;
getdate(year, month, day);
new playerip[32];
GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
format(string, sizeof(string), "AdmCmd: %s (IP:%s) was kicked by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
Log("logs/kick.log", string);
if(PlayerInfo[playerid][pAdmin] == 1) Log("logs/moderator.log", string);
format(string, sizeof(string), "AdmCmd: %s was kicked by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_LIGHTRED, string);
Kick(giveplayerid);
}
return 1;
}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

My Kick COde i don't know what is the proplem i can't fix it each time i use it it just fail


Re: Need Help {+Rep} - Twisted_Insane - 20.03.2012

Hmm...I'mma give you mine, just insert your other things you want! Define this at the top of your script:

pawn Код:
#define kickPATH            "Logs/KickLog.txt" //directory for kicks
pawn Код:
CMD:kick(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdmin] >= 3) {
            new PID;
            new reason[64];
            new str[128];
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Adminname, sizeof(Adminname));
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]");

            if(!IsPlayerConnected(PID))
                return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");

            format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
            SendClientMessageToAll(COLOR_RED, str);
            new File:Log = fopen(kickPATH, io_append);
            new logData[128];
            new fTime[6];
            getdate(fTime[0], fTime[1], fTime[2]);
            gettime(fTime[3], fTime[4], fTime[5]);
            format(logData, sizeof logData, "[%02d/%02d/%04d || %02d:%02d:%02d]%s kicked %s! (Reason: %s) \r\n", fTime[2], fTime[1], fTime[0], fTime[3], fTime[4], fTime[5], Adminname, Playername, reason);
            fwrite(Log, logData);
            fclose(Log);
            Kick(PID);

        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!");
        }
        return 1;
    }