SA-MP Forums Archive
[Include] [INC]EasyNames - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] [INC]EasyNames (/showthread.php?tid=51289)

Pages: 1 2


[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:
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