SA-MP Forums Archive
Admin Command - 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: Admin Command (/showthread.php?tid=496372)



Admin Command - Miia - 21.02.2014

Help me please. I tried to fix this many times, but when i kick the player it gives the text, add it to log and everything, but it doesn't kick him off the server.

Код:
if(strcmp(cmd, "/kick", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid/PartOfName] [reason]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(IsPlayerNPC(giveplayerid)) return 1;
			if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 4)
			{
				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: /kick [playerid/PartOfName] [reason]");
							return 1;
						}
						new logstring[256];
						new year, month, day;
						getdate(year, month, day);
						if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
						{
						    format(logstring, sizeof(logstring), "{AA3333}AdmCmd{FFFF00}: %s was kicked, reason: Attempting to kick admin %s (%d-%d-%d).", sendername, giveplayer,month,day,year);
						    KickLog(logstring);
						    format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was kicked, reason: Attempting to kick a higher admin.", sendername);
							SendClientMessageToAll(COLOR_LIGHTRED, string);
							SetTimerEx("GettingKicked", 2000, false, "i", giveplayer);
							return 1;
						}
						format(logstring, sizeof(logstring), "{AA3333}AdmCmd{FFFF00}: %s was kicked by %s, reason: %s (%d-%d-%d).", giveplayer, sendername, (result),month,day,year);
						KickLog(logstring);
						format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was kicked by %s, reason: %s", giveplayer, sendername, (result));
						SendClientMessageToAll(COLOR_LIGHTRED, string);
						SetTimerEx("GettingKicked", 2000, false, "i", giveplayer);
						
						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;
	}



Re: Admin Command - Mattakil - 21.02.2014

why the hell is that command longer than my penis? You don't need all of that shit, lol.

Use sscanf and zcmd, its a lot easier.

pawn Код:
CMD:kick(playerid, params[])
{
    new reason[100], target;
    if(PlayerInfo[pid][pAdmin] < 1) return ErrorMessage(pid, "You aren't authorized to use this command.");
    if(sscanf(params, "us[100]", target, reason)) return UsageMessage(pid, "/kick [target][reason]");
    format(reason, sizeof(reason), "%s has been kicked by %s for: %s", GetName(target), GetName(pid), reason);
    KickWithMessageToAll(target, COLGREEN, reason);
    return 1;
}
pawn Код:
forward KickPublic1(playerid);
public KickPublic1(playerid) { Kick(playerid); }

stock KickWithMessageToAll(playerid, color, message[])
{
    SendClientMessageToAll(color, message);
    SetTimerEx("KickPublic1", 100, 0, "d", playerid);
}
EDIT: Its from my script, I have custom functions so you may have to play with some things


Re: Admin Command - Dignity - 21.02.2014

EDIT: Matt was first, lol.