/fakeban command fucked up - using wrong IDґs
#1

Hey there,

Iґve scripted some little command for the lolz, /fakeban. It kicks players and sends the same message when banning ^_^ Itґs great to have some fun.

Код:
 	if(strcmp(cmd, "/fakeban", true) == 0) // Kicks the player from the server
	{
		new reason[128];
		if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
		{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "USAGE: /fakeban [playername/id] [reason]");
				SendClientMessage(playerid, ORANGE, "FUNCTION: Will kick the specified player.");
				return 1;
			}
			if(giveplayerid != INVALID_PLAYER_ID)
				{
			  GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
				GetPlayerName(playerid, sendername, sizeof(sendername));
				reason = bigstrtok(cmdtext, idx);
				if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /fakeban [playername/id] [reason]");
				printf("ADMIN: Admin %s kicked %s. Reason: %s", sendername, giveplayername, reason);
				format(string, sizeof(string), "-| Administrator %s banned %s. [Reason: %s ] |-", sendername, giveplayername, reason);
				SendClientMessageToAll(ADMIN_RED, string);
				Kick(giveplayerid);
				KickLog(string);
				}
				else if(giveplayerid == INVALID_PLAYER_ID)
			{
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, RED, string);
			}
		}
		else SendClientMessage(playerid, RED, "You are not an admin with the required level.");
		return 1;
	}
But the command seems not to use the correct IDґs, everytime I enter /fakeban 12, it kicks ID 18, and so on. Whereґs the problem?
Reply
#2

Код:
if(strcmp(cmd, "/fakeban", true) == 0) // Kicks the player from the server
{
	new reason[128];
	if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, ORANGE, "USAGE: /fakeban [playerid] [reason]");
			SendClientMessage(playerid, ORANGE, "FUNCTION: Will kick the specified player.");
			return 1;
		}
		giveplayerid = strval(tmp);
		reason = bigstrtok(cmdtext, idx);
		if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /fakeban [playerid] [reason]");
		if(IsPlayerConnected(giveplayerid))
		{
			GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			printf("ADMIN: Admin %s kicked %s. Reason: %s", sendername, giveplayername, reason);
			format(string, sizeof(string), "-| Administrator %s banned %s. [Reason: %s ] |-", sendername, giveplayername, reason);
			SendClientMessageToAll(ADMIN_RED, string);
			Kick(giveplayerid);
			KickLog(string);
		}
		else
		{
		format(string, sizeof(string), "%d is not an active player.", giveplayerid);
		SendClientMessage(playerid, RED, string);
		}
	}
	else SendClientMessage(playerid, RED, "You are not an admin with the required level.");
	return 1;
}
Reply
#3

Still fucked up - now including message: Server: Command not found..
Reply
#4

Do U have on top commandtext
Код:
new cmd[128],idx,tmp[128];
cmd = strtok(cmdtext,idx);
?
Reply
#5

Dude, dont u c dat u never set giveplayerid??
Reply
#6

Quote:
Originally Posted by Jefff
Do U have on top commandtext
Код:
new cmd[128],idx,tmp[128];
cmd = strtok(cmdtext,idx);
?
What's this useless spam for? Read his problem before posting this..

pawn Код:
dcmd_fakeban(playerid,params[])
{
  if(!AccountInfo[playerid][AdminLevel]) return SendClientMessage(playerid,color,"You are not an admin.");
  new
    id,
    reason[64],
    pName[MAX_PLAYER_NAME],
    pName2[MAX_PLAYER_NAME];

  if(sscanf(params,"us",id,reason)) return SendClientMessage(playerid,color,"Usage: /fakeban [playerid/name] [reason]");
  if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color,"That player ain't connected.");
  GetPlayerName(playerid,pName,sizeof(pName));
  GetPlayerName(id,pName2,sizeof(pName2));
  printf("ADMIN: Admin %s kicked %s. Reason: %s",pName,pName2,reason);
  format(string,sizeof(string),"-| Administrator %s banned %s. [Reason: %s ] |-",pName,pName2,reason);
  SendClientMessageToAll(ADMIN_RED, string);
  Kick(id);
  KickLog(string);
  return 1;
}
Have fun.
Reply
#7

just copy /ban but take out the ban(playerid) and the printf stuff
Reply
#8

Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by Jefff
Do U have on top commandtext
Код:
new cmd[128],idx,tmp[128];
cmd = strtok(cmdtext,idx);
?
What's this useless spam for? Read his problem before posting this..

pawn Код:
dcmd_fakeban(playerid,params[])
{
  if(!AccountInfo[playerid][AdminLevel]) return SendClientMessage(playerid,color,"You are not an admin.");
  new
    id,
    reason[64],
    pName[MAX_PLAYER_NAME],
    pName2[MAX_PLAYER_NAME];

  if(sscanf(params,"us",id,reason)) return SendClientMessage(playerid,color,"Usage: /fakeban [playerid/name] [reason]");
  if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color,"That player ain't connected.");
  GetPlayerName(playerid,pName,sizeof(pName));
  GetPlayerName(id,pName2,sizeof(pName2));
  printf("ADMIN: Admin %s kicked %s. Reason: %s",pName,pName2,reason);
  format(string,sizeof(string),"-| Administrator %s banned %s. [Reason: %s ] |-",pName,pName2,reason);
  SendClientMessageToAll(ADMIN_RED, string);
  Kick(id);
  KickLog(string);
  return 1;
}
Have fun.
U read too special kid.
He want normal cmd with strtok so dont post shit with dcmd.
Reply
#9

Quote:
Originally Posted by Mowgli
just copy /ban but take out the ban(playerid) and the printf stuff
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)