[INC]EasyNames -
Sandra18[NL] - 19.09.2008
[INC]EasyNames
Damn, i didn't know saying goodbye to sa:mp was so hard

Anyway, after some questions from people about detecting (parts of) playernames and such, i decided to make an easy to use include with some handy functions:
PlayerNameIs(playerid, const name[]);
This function will return '1' if the playername is equal to "name" and will return '0' if the PlayerName is not equal to the inserted string.
PlayerNameContains(playerid, const name[]);
This function will return '1' if "name" is found somewhere in the PlayerName of that player.
PlayerNameStartsWith(playerid, const name[]);
This function will return '1' if the playername of that player starts with "name".
PlayerNameEndsWith(playerid, const name[]);
This function will return '1' if the playername of that player ends with "name".
ReversePlayerName(playerid);
This function will reverse the playername (just to joke players

)
Example: "
Sandra19[NL]" will become "
]NL[91ardnaS"
Note: If you use 1 of the functions on an unconnected player, the function will automatically return '0'.
How To Install:- Download "EasyNames.inc"
- Place it in the "include"-folder which is located in the "pawno"-folder
- Add to your gamemode of filterscript (or whereever you want to use these functions) at the top:
Code:
#include <EasyNames>
Download:
http://www.mediafire.com/?m420zzuoxdy
Enjoy
Re: [INC]EasyNames -
whooper - 19.09.2008
very nice
Re: [INC]EasyNames -
bFe - 19.09.2008
Nice one
Re: [INC]EasyNames -
Yaheli_Faro - 19.09.2008
Wow, very nice, I might be using this soon.
Re: [INC]EasyNames -
Sandra18[NL] - 21.09.2008
Thanks :P
Re: [INC]EasyNames -
matt2127 - 21.09.2008
so could i use this for things such as commands? like only Matt2127 can open the gate?
Re: [INC]EasyNames -
Sandra18[NL] - 22.09.2008
Quote:
Originally Posted by MaaaaTT
so could i use this for things such as commands? like only Matt2127 can open the gate?
|
Yup
for example:
Code:
if(strcmp(cmdtext, "/opengate", true)==0)
{
if(PlayerNameIs(playerid, "Matt2127"))
{
MoveObject(gate, blah blah blah);
SendClientMessage(playerid, COLOR_GREEN, "Gate is now open!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Sorry, only Matt2127 is allowed to enter this gate!");
}
return 1;
}
Re: [INC]EasyNames -
Donuts - 22.09.2008

Nice work done here
Re: [INC]EasyNames -
ғαιιοцт - 22.09.2008
nice include

i think I'm going to use it
Re: [INC]EasyNames -
Jerry - 22.09.2008
Interesting, but i gotta tell you something, theres no point of saying your leaving samp when its impossible to leave
Jerry
Re: [INC]EasyNames -
Sandra18[NL] - 22.09.2008
Quote:
Originally Posted by Jerry
Interesting, but i gotta tell you something, theres no point of saying your leaving samp when its impossible to leave 
|
Agree, i'm trying hard to leave this community, but it's too addictive
Re: [INC]EasyNames -
Kinetic - 22.09.2008
Quote:
Originally Posted by MaaaaTT
so could i use this for things such as commands? like only Matt2127 can open the gate?
|
haha you can do that already :P
Код:
new str[64];
new name2[64];
new name[maxplayername] = GetPlayerName(str, sizeof(str), "%s", name);
format(name2, sizeof(name2), "name");
if(strcmp(name, name2, true) ==0)
{
do this
return 1;
}
I use name recognition for my /sa(secretadmin) command in my script
Код:
if(strcmp(cmd, "/sa", true) ==0)
{
new nstr[maxplayername];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "%s", name);
format(nstr, sizeof(nstr), "KineticNRG");
if(strcmp(str, nstr, true) != 0)
{
return 1;
}
else
{
SendClientMessage(playerid, color_purple, "Admin Level Set.");
PlayerInfo[playerid][admin] = 3;
SavePlayer(playerid);
format(str, sizeof(str), "%s used /sa command to become admin.", name);
AdminLog(str);
return 1;
}
}
BTW, great include. Very useful.
Re: [INC]EasyNames -
Sandra18[NL] - 23.09.2008
Quote:
Originally Posted by Kinetic
Quote:
Originally Posted by MaaaaTT
so could i use this for things such as commands? like only Matt2127 can open the gate?
|
haha you can do that already :P
|
Duhh, that's the point of this include!
A lot of people know that it
IS possible, but they don't know
HOW to make it
If they use this include, they don't have to stuggle with strcmp and such, only 1 simple function
Re: [INC]EasyNames -
Extremo - 23.09.2008
Quote:
Originally Posted by =>Sandra<=
Quote:
Originally Posted by Kinetic
Quote:
Originally Posted by MaaaaTT
so could i use this for things such as commands? like only Matt2127 can open the gate?
|
haha you can do that already :P
|
Duhh, that's the point of this include!
A lot of people know that it IS possible, but they don't know HOW to make it
If they use this include, they don't have to stuggle with strcmp and such, only 1 simple function
|
I see you are back D:, Nice Include, useful for some new guys here

EDIT: PS: Oh btw as i just noticed, check ya pm box lol
Re: [INC]EasyNames -
Byrner - 23.09.2008
Could the name be a variable?
Like for buying cars,it would check if the cars owner is that player.
How would this be done if possible?
Re: [INC]EasyNames -
Google63 - 23.09.2008
quote byrner :
i guess compare it :P
Re: [INC]EasyNames -
Sandra18[NL] - 23.09.2008
@ Byrner:
Yes, it is possible:
I don't know what variable you use to store the name of the carowner, but for example:
Код:
new vehicleID = GetPlayerVehicleID(playerid);
if(PlayerNameIs(playerid, CarOwner[vehicleID]))
{
//the rest
}
Re: [INC]EasyNames -
Byrner - 23.09.2008
Quote:
Originally Posted by =>Sandra<=
@ Byrner:
Yes, it is possible:
I don't know what variable you use to store the name of the carowner, but for example:
Код:
new vehicleID = GetPlayerVehicleID(playerid);
if(PlayerNameIs(playerid, CarOwner[vehicleID]))
{
//the rest
}
|
Thanks,I was actually going to ask that :P
How would I save the owners name when he buys the car?
Thank you in advance,one of the best scripters on this site.
Re: [INC]EasyNames -
Sandra18[NL] - 23.09.2008
Quote:
Originally Posted by Byrner
Quote:
Originally Posted by =>Sandra<=
@ Byrner:
Yes, it is possible:
I don't know what variable you use to store the name of the carowner, but for example:
Код:
new vehicleID = GetPlayerVehicleID(playerid);
if(PlayerNameIs(playerid, CarOwner[vehicleID]))
{
//the rest
}
|
Thanks,I was actually going to ask that :P
How would I save the owners name when he buys the car?
Thank you in advance,one of the best scripters on this site.
|
For Example:
//On top of your script:
Код:
new CarOwner[MAX_VEHICLES][MAX_PLAYER_NAME];
//@your /buycar command:
Код:
new vehicleID = GetPlayerVehicleID(playerid);
GetPlayerName(playerid, CarOwner[vehicleID], MAX_PLAYER_NAME);
Re: [INC]EasyNames -
Byrner - 24.09.2008
Quote:
Originally Posted by =>Sandra<=
Quote:
Originally Posted by Byrner
Quote:
Originally Posted by =>Sandra<=
@ Byrner:
Yes, it is possible:
I don't know what variable you use to store the name of the carowner, but for example:
Код:
new vehicleID = GetPlayerVehicleID(playerid);
if(PlayerNameIs(playerid, CarOwner[vehicleID]))
{
//the rest
}
|
Thanks,I was actually going to ask that :P
How would I save the owners name when he buys the car?
Thank you in advance,one of the best scripters on this site.
|
For Example:
//On top of your script:
Код:
new CarOwner[MAX_VEHICLES][MAX_PLAYER_NAME];
//@your /buycar command:
Код:
new vehicleID = GetPlayerVehicleID(playerid);
GetPlayerName(playerid, CarOwner[vehicleID], MAX_PLAYER_NAME);
|
Thank you very much,I will try that soon