SA-MP Forums Archive
Name bugged - 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: Name bugged (/showthread.php?tid=350511)



Name bugged - jtemple042996 - 12.06.2012

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.


Re: Name bugged - Yuryfury - 13.06.2012

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


Re: Name bugged - Aira - 13.06.2012

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


Re: Name bugged - JhnzRep - 13.06.2012

Update sscanf.


Re: Name bugged - jtemple042996 - 14.06.2012

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;
}


Re : Name bugged - vernz - 14.06.2012

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


Re: Name bugged - Djole1337 - 14.06.2012

Код:
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.


Re: Name bugged - Mike97300 - 14.06.2012

Try adding this,

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

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



Re: Name bugged - jtemple042996 - 15.06.2012

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


Re: Name bugged - jtemple042996 - 18.06.2012

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