SA-MP Forums Archive
Making /ban and /kick without the name - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Making /ban and /kick without the name (/showthread.php?tid=93335)



Making /ban and /kick without the name - Hiitch - 24.08.2009

Hey guys, it's me again, I just wanted to ask, is there a possible way to make the /kick and /ban without using ReturnUser and just the ID?

This is my code (given to me by someone)

Kick command

Код:
  if(strcmp(cmd, "/kick", true) == 0) if(Logged[playerid] == 1)
	{
	  if(IsPlayerConnected(playerid))
	  {
	  	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid/PartOfName] [reason(optional)]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(GetPlayerAdminz(playerid) < 1) return 0;
			{
				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[64];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							format(string, sizeof(string), "[ ! ] %s has been kicked by %s !", giveplayer, sendername);
							SendClientMessageToAll(AC_COLOR, string);
							KickLog(string);
							Kick(giveplayerid);
							TogglePlayerControllable(giveplayerid,0);
							return 1;
						}
						format(string, sizeof(string), "[ ! ] %s has been kicked by %s for %s !", giveplayer, sendername,result);
						SendClientMessageToAll(AC_COLOR, string);
						KickLog(string);
						Kick(giveplayerid);
						TogglePlayerControllable(giveplayerid,0);
						return 1;
					}
				}
			}
		}
		return 1;
	}
This is the ban command

Код:
  if(strcmp(cmd, "/ban", true) == 0) if(Logged[playerid] == 1)
	{
	  if(IsPlayerConnected(playerid))
	  {
	  	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/PartOfName] [reason]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(GetPlayerAdminz(playerid) < 1) return 0;
			{
				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[64];
						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: /ban [playerid/PartOfName] [reason]");
							return 1;
						}
						format(string, sizeof(string), "[ ! ] %s has been banned by %s for %s !", giveplayer, sendername,result);
						SendClientMessageToAll(AC_COLOR, string);
						BanLog(string);
						Ban(giveplayerid);
						TogglePlayerControllable(giveplayerid,0);
						return 1;
					}
				}
			}
		}
		return 1;
	}
Any help would be appreciated

-- Hiitch[WS]


Re: Making /ban and /kick without the name - Zeex - 24.08.2009

Just replace
pawn Код:
giveplayerid = ReturnUser(tmp);
to
pawn Код:
giveplayerid = strval(tmp);



Re: Making /ban and /kick without the name - Hiitch - 24.08.2009

This worked, thank you !


Re: Making /ban and /kick without the name - ronald - 30.08.2009

Guys since you're talking about this, where should i add this command?
I have administrator on my server, but i don't have any commands for administrators...can you tell me where i should put the ban command? On my game mode? or the filterscript?


Re: Making /ban and /kick without the name - Google63 - 30.08.2009

sscanf(); - data type: u - works too...