[Include] [INC]EasyNames
#1

[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
Reply
#2

very nice
Reply
#3

Nice one
Reply
#4

Wow, very nice, I might be using this soon.
Reply
#5

Thanks :P
Reply
#6

so could i use this for things such as commands? like only Matt2127 can open the gate?
Reply
#7

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;
}
Reply
#8

Nice work done here
Reply
#9

nice include i think I'm going to use it
Reply
#10

Interesting, but i gotta tell you something, theres no point of saying your leaving samp when its impossible to leave





Jerry
Reply
#11

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
Reply
#12

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.
Reply
#13

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

Reply
#14

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
Reply
#15

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?
Reply
#16

quote byrner :
i guess compare it :P
Reply
#17

@ 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
}
Reply
#18

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.
Reply
#19

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);
Reply
#20

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)