Paste ID into Name
#1

Hey Community...

Here i go again with another question:
Today i just tried to paste the Id of the Player into his name, and used this code:

Код:
public OnPlayerSpawn(playerid)
{
new CurrentName[MAX_PLAYER_NAME];
new CurrentID;
new NewName[128];
GetPlayerName(playerid,CurrentName,sizeof(CurrentName));
CurrentID = GetPlayerID("CurrentName");
format(NewName,sizeof(NewName),"%s[%i]",CurrentName,CurrentID);
SetPlayerName(playerid,NewName);

return 1;
}
It doesnt give me Errors or warnings, but the problem is, that it doesnt work :/
Pls tell me what i did wrong!

Greetings from Germany,
DeathOnaStick
Reply
#2

Why do you need GetPlayerID? It's already stored in "playerid"

By the way, its not working because you put "CurrentName" in quotes, which makes it a string, its searching for "CurrentName" and not the name thats defined in the variable, just change it to:

GetPlayerID(CurrentName);

Also, you don't need to do that anyway, just add playerid to the end of the format instead of CurrentID
Reply
#3

Because i needed to use it in format.... didnt know how to do it another way =D... Seemed to be the easiest way for me
Reply
#4

Quote:
Originally Posted by DeathOnaStick
Because i needed to use it in format.... didnt know how to do it another way =D... Seemed to be the easiest way for me
just replace CurrentID with playerid in the format function
Reply
#5

Thanks very much, it worked, but can you tell me actually WHY it didnt work? XD
Reply
#6

Quote:
Originally Posted by DeathOnaStick
Thanks very much, it worked, but can you tell me actually WHY it didnt work? XD
I've explained why it didn't work in my post
Reply
#7

lol sry didnt see :/

btw... thanks very much =D
Reply
#8

i use this on everystuff. ill post the code in a second (will add to this post)

In OnPlayerText:

Код:
new textmsg[128];
format(textmsg,sizeof(textmsg),"[%d] %s", playerid,text);
SendPlayerMessageToAll(playerid, textmsg);
return 0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)