PlayerName -
Kwarde - 04.07.2011
Hi.
I just made an include (mostly for myself), but I'm gonna share it

.
What is it
Very simple. It has an new 'SetPlayerName'. Example:
Old SetPlayerName:
I have the name 'kwarde'. I want 'Kwarde'. So I use SetPlayerName. It doesn't work!! (Because of the capitals, the name is the same, the server returns :P).
My new SetPlayerName:
I have the name 'kwarde'. I want 'Kwarde'. So I use SetPlayerName. It works!!!
And it has an 'PlayerName(playerid)' to get someone's name. You can either use that, or 'playerName[playerid]'. Your choise.
So it's just simple, but quite usefull, because it's easier to use. Example scripts:
Normal way
pawn Код:
new pName[MAX_PLAYER_NAME], str[128]; //Overused cells
GetPlayerName(playerid, pName, sizeof(pName));
format(str, 128, "Hi %s!", pName);
SendClientMessage(playerid, 0xFFFFFFAA, str);
New way
pawn Код:
new str[128]; //Overused cells :P
format(str, 128, "Hi %s!", playerName[playerid]); //Or instead of 'playerName[playerid]' PlayerName(playerid)
SendClientMessage(playerid, 0xFFFFFFAA, str);
It's not special, EXCEPT that this scripts uses a global variable:
new playerName[MAX_SLOTS][MAX_PLAYER_NAME];
The most people makes all the time a new 'pName', but this script doesn't

.
Download
Version 1.0:
Pastebin
Changelog
Код:
Version 1.0:
- Initial release
Instructions
1) Copy the script from pastebin into PAWNO
2) (Optional) Change 'MAX_PLAYERS' to the max slots of your server (if it wasn't done already!)
3) Save the file in your pawno/include folder
4) Add
#include <{name}> to your gamemode/filterscript. NOTE: Change {name} for the name of the .inc file. TIP: Use PlayerName
That's it. Kinda simple, but also quite usefull (My opinion !!)
- Kevin
p.s.
I know I wouldn't release scripts anymore, seems like I changed my mind :P
Re: PlayerName -
XpDeviL - 04.07.2011
Thank dude.
AW: PlayerName -
Forbidden - 04.07.2011
Good work,will be usefull for lazy people
Re: AW: PlayerName -
iPLEOMAX - 04.07.2011
Quote:
Originally Posted by Forbidden
Good work,will be usefull for lazy people 
|
Actually also for those who wants to save their time.

Thanks Kwarde. +rep
Re: PlayerName -
Kwarde - 04.07.2011
Don't forget this part! :P
Quote:
Old SetPlayerName:
I have the name 'kwarde'. I want 'Kwarde'. So I use SetPlayerName. It doesn't work!! (Because of the capitals, the name is the same, the server returns :P).
My new SetPlayerName:
I have the name 'kwarde'. I want 'Kwarde'. So I use SetPlayerName. It works!!!
|
And thanks everyone :P. Or should I say: "You're welcome"?
Re: PlayerName -
FireCat - 04.07.2011
So basicly a SetPlayerName fix?
Good idea
Re: PlayerName -
Kwarde - 04.07.2011
Yes, and just -very old- a PlayerName(playerid); function (or just use:
playerName[playerid] (var). The most PlayerName functions looks like this:
pawn Код:
stock PlayerName(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName)); //Or instead of 'sizeof(pName)' just 'MAX_PLAYER_NAME' (my style)
return pName;
}
My script has the global variable "playerName[playerid]". (
new playerName[MAX_PLAYERS][MAX_PLAYER_NAME];). When a player connects, the script automatic gets the name, store it into playerName[playerid] so you can safe it later (yes it's being changed when you use SetPlayerName).
And so, the PlayerName function of mine looks like this:
pawn Код:
stock PlayerName(playerid)
return playerName[playerid];
:P
Re: PlayerName -
legodude - 05.07.2011
most funnctions can be made out of definnes, improves speed of script. jjust a hint

other than that, quite useful
Re: PlayerName -
Kwarde - 05.07.2011
Quote:
Originally Posted by legodude
most funnctions can be made out of definnes, improves speed of script. jjust a hint 
other than that, quite useful
|
Where are you talking about? There are only 2 functions, one of it can be used as a macro (it actually can, but it's quite big and that doesn't really fit to macro's) and the other one, well, that's not "most functions".
pawn Код:
stock NewName(playerid, const name[])
{
new str[MAX_PLAYER_NAME];
format(str, MAX_PLAYER_NAME, "x_%03d_", playerid);
SetPlayerName(playerid, str); //Eg. if you have the name 'kwarde' and you want 'Kwarde', normal SetPlayerName won't work. This'll fix it
SetPlayerName(playerid, name);
GetPlayerName(playerid, playerName[playerid], MAX_PLAYER_NAME);
return 1;
}
#define SetPlayerName NewName
stock PlayerName(playerid)
return playerName[playerid];
#define Name PlayerName
Do you see what I mean?
Re: PlayerName -
juraska - 05.07.2011
First is good idea

. Second it's nice job
Re: PlayerName -
SmileyForCheat - 05.07.2011
I Do Not Need to Use?
pawn Code:
new pName[MAX_PLAYER_NAME], str[128]; //Overused cells
GetPlayerName(playerid, pName, sizeof(pName));
Re: PlayerName -
Stepashka - 05.07.2011
As old as time.
Re: PlayerName -
Hiddos - 05.07.2011
This would still mean a shitload of 'overused' cells. What would be more efficient? To create one string with 24 cells ONLY when you need to retrieve a name
OR having
x* strings with 24 cells ALL the time, meaning they're 99.9% of the time useless?
* Whatever MAX_PLAYERS is defined as.
Re: PlayerName -
Stepashka - 05.07.2011
Quote:
Originally Posted by Hiddos
This would still mean a shitload of 'overused' cells. What would be more efficient? To create one string with 24 cells ONLY when you need to retrieve a name OR having x* strings with 24 cells ALL the time, meaning they're 99.9% of the time useless?
* Whatever MAX_PLAYERS is defined as.
|
do not create extra lines!
pawn Code:
new str[128]; //Overused cells
GetPlayerName(playerid, str, MAX_PLAYER_NAME);
format(str, 128, "Hi %s!", str);
SendClientMessage(playerid, 0xFFFFFFAA, str);
Re: PlayerName -
Hiddos - 05.07.2011
Quote:
Originally Posted by Stepashka
do not create extra lines!
pawn Code:
new str[128]; //Overused cells GetPlayerName(playerid, str, MAX_PLAYER_NAME); format(str, 128, "Hi %s!", str); SendClientMessage(playerid, 0xFFFFFFAA, str);
|
+1, best solution around ^^
Re: PlayerName -
System64 - 05.07.2011
I don't under stand why this if you have GetName function by Y_Less?
anyway nice
Re: PlayerName -
][Noname][ - 05.07.2011
In audio plugin 0.5 redefine of setplayername, you must know it