PDA

View Full Version : Name bugged


jtemple042996
12/06/2012, 08:57 PM
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.

Yuryfury
13/06/2012, 03:50 AM
You mean GetPlayerName returns the incorrect player name? Can't help unless we see the code...

Aira
13/06/2012, 06:45 AM
He means /kick YuryFury = Kicks ME instead or someone else

JhnzRep
13/06/2012, 06:49 AM
Update sscanf.

jtemple042996
14/06/2012, 06:09 PM
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;
}

vernz
14/06/2012, 06:11 PM
Use easier to read... and like someone said above, update your sscanf.

Djole1337
14/06/2012, 06:15 PM
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.

Mike97300
14/06/2012, 08:06 PM
Try adding this,

new targetid;
new giveplayerid;

For example if you want the player id to receive a message

SendClientMessage(targetid, COLOR_WHITE, "Test");

jtemple042996
15/06/2012, 09:16 PM
I just updated my sscanf and i still just have ID 0 bug :S

jtemple042996
18/06/2012, 02:52 AM
Well actually, instead of the Player ID it does 6464 or something like that.

Unfriendly
18/06/2012, 03:00 AM
This happened to me upon loading the user skin. It set it to either 0 or 5, regardless of what was saved in the file.
I know there's not a file saved for player ids, but yeah... same thing.

Try this:

//Ask a player to kick themselves for whatever reason.

CMD:kick(playerid, params[])
{
SendClientMessage(playerid, -1, "Thanks for complying.");
kick(playerid);
return 1;
}