Name bugged
#1

I scripted an admin system, I will post the relevant Code later but instead of getting the target players name it selects a random name of a player on the server.

Again I'm on a mobile I will post the code when I get on my PC.
Reply
#2

You mean GetPlayerName returns the incorrect player name? Can't help unless we see the code...
Reply
#3

He means /kick YuryFury = Kicks ME instead or someone else
Reply
#4

Update sscanf.
Reply
#5

Ok, well i updated Sscanf but now there is a new problem instead of the actual playerid the script shows 65635:

COMMAND:warn(playerid,params[])
{
new id,reason[128],pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],sstring[MAX_PLAYER_NAME+128],astring[MAX_PLAYER_NAME+128],pstring[MAX_PLAYER_NAME+128];
GetPlayerName(playerid,aname,sizeof(aname));
GetPlayerName(id,pname,sizeof(pname));
if(alevel[playerid] >= 1)
{
if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,0xFFFFFFFF,"Correct Usage: /warn id reason");
if(id == playerid) return SendClientMessage(playerid,0xFF0000FF,"You can not use this command on yourself!");
format(sstring,sizeof(sstring),"Administrator %s(%i) has warned %s(%i) for %s",aname,playerid,pname,id,reason);
format(astring,sizeof(astring),"You have warned %s(%i) for %s",pname,id,reason);
format(pstring,sizeof(pstring),"You have been warned by Administrator %s(%i) for %s",aname,playerid,reason);
SendClientMessageToAll(0xFF0000FF,sstring);
SendClientMessage(playerid,0xE38217,astring);
SendClientMessage(id,0xE38217,pstring);
}
else
{
SendClientMessage(playerid,0xFF0000FF,"You are not authorized to use that command!");
}
return 1;
}
COMMAND:kick(playerid,params[])
{
new id,reason[128],pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],sstring[MAX_PLAYER_NAME+128],astring[MAX_PLAYER_NAME+128],pstring[MAX_PLAYER_NAME+128];
GetPlayerName(playerid,aname,sizeof(aname));
GetPlayerName(id,pname,sizeof(pname));
if(alevel[playerid] >= 1)
{
if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,0xFFFFFFFF,"Correct Usage: /kick id reason");
if(id == playerid) return SendClientMessage(playerid,0xFF0000FF,"You can not use this command on yourself!");
format(sstring,sizeof(sstring),"Administrator %s(%i) has kick %s from the server for %s",aname,playerid,pname,reason);
format(astring,sizeof(astring),"You have kicked %s from the server for %s",pname,reason);
format(pstring,sizeof(pstring),"You have been kicked from the server by Administrator %s(%i) for %s",aname,playerid,reason);
SendClientMessageToAll(0xFF0000FF,sstring);
SendClientMessage(playerid,0xE38217,astring);
SendClientMessage(id,0xE38217,pstring);
Kick(id);
}
else
{
SendClientMessage(playerid,0xFF0000FF,"You are not authorized to use that command!");
}
return 1;
}
Reply
#6

Use easier to read... and like someone said above, update your sscanf.
Reply
#7

Код:
COMMAND:warn(playerid,params[])
{
new id,reason[128],pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],sstring[MAX_PLAYER_NAME+128],astring[MAX_PLAYER_NAME+128],pstring[MAX_PLAYER_NAME+128];
GetPlayerName(playerid,aname,sizeof(aname));
GetPlayerName(id,pname,sizeof(pname));
if(alevel[playerid] >= 1)
{
if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,0xFFFFFFFF,"Correct Usage: /warn id reason");
if(id == playerid) return SendClientMessage(playerid,0xFF0000FF,"You can not use this command on yourself!");
format(sstring,sizeof(sstring),"Administrator %s(%i) has warned %s(%i) for %s",aname,playerid,pname,id,reason);
format(astring,sizeof(astring),"You have warned %s(%i) for %s",pname,id,reason);
format(pstring,sizeof(pstring),"You have been warned by Administrator %s(%i) for %s",aname,playerid,reason);
SendClientMessageToAll(0xFF0000FF,sstring);
SendClientMessage(playerid,0xE38217,astring);
SendClientMessage(id,0xE38217,pstring);
}
else
{
SendClientMessage(playerid,0xFF0000FF,"You are not authorized to use that command!");
}
return 1;
}
COMMAND:kick(playerid,params[])
{
new id,reason[128],pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],sstring[MAX_PLAYER_NAME+128],astring[MAX_PLAYER_NAME+128],pstring[MAX_PLAYER_NAME+128];
GetPlayerName(playerid,aname,sizeof(aname));
GetPlayerName(id,pname,sizeof(pname));
if(alevel[playerid] >= 1)
{
if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,0xFFFFFFFF,"Correct Usage: /kick id reason");
if(id == playerid) return SendClientMessage(playerid,0xFF0000FF,"You can not use this command on yourself!");
format(sstring,sizeof(sstring),"Administrator %s(%i) has kick %s from the server for %s",aname,playerid,pname,reason);
format(astring,sizeof(astring),"You have kicked %s from the server for %s",pname,reason);
format(pstring,sizeof(pstring),"You have been kicked from the server by Administrator %s(%i) for %s",aname,playerid,reason);
SendClientMessageToAll(0xFF0000FF,sstring);
SendClientMessage(playerid,0xE38217,astring);
SendClientMessage(id,0xE38217,pstring);
Kick(id);
}
else
{
SendClientMessage(playerid,0xFF0000FF,"You are not authorized to use that command!");
}
return 1;
}
Code looks good... Try updating sscanf, remember to delete old one before you paste new.
Reply
#8

Try adding this,

Код:
new targetid;
   	new giveplayerid;
For example if you want the player id to receive a message

Код:
SendClientMessage(targetid, COLOR_WHITE, "Test");
Reply
#9

I just updated my sscanf and i still just have ID 0 bug :S
Reply
#10

Well actually, instead of the Player ID it does 6464 or something like that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)