Jump to content
  • 0

pomoc Porovnávanie mena


Jurajvocny

Dotaz

Ahojte.

 

Mam taký problém. Robím si admin systém a neviem si rady s jednou vecou.

Nastavil som si v new meno a chcem ho porovnať s menom hráča.

Tu je môj kód.

new static Majitel[MAX_PLAYER_NAME] = "Jozo";

stock IsPlayerOwner(playerid)
{
	if(strfind(PlayerName(playerid), Majitel[playerid], true, 4)) return 1;
	else return 0;
} 

Teraz my to robí to že keď dám akékoľvek meno tak mi to dá majitela.

 

No neviem keby ste vedeli tak píšte.

Ďakujem. 

Edited by Jurajvocny
Link to comment
Share on other sites

8 odpovědí na tuto otázku

Recommended Posts

  • 0
  • Globální moderátor

https://wiki.sa-mp.com/wiki/Strfind 

 

4. parametr – Position (optional)The offset to start searching from.

Return – The number of characters before the sub string (the sub string's start position) or -1 if it's not found.

 

Nastavuješ z nějakého důvodu offset na 4 a pak ještě tu podmínku máš víceméně špatně. 

 

Každopádně pro porovnání jména bych spíš použil strcmp. 

 

https://wiki.sa-mp.com/wiki/Strcmp

Edited by HighPrint
Link to comment
Share on other sites

  • 0

Ok.  

Ja som myslel  písmená v mene keď sa prihlásim do hry.

Keď si dám meno Joz (alebo úplne iné meno) tak nie som majiteľ, keď Jozo tak som a keď Jozo1 tak tiež som ale mal by byť len Jozo.

Chápete?  

Link to comment
Share on other sites

  • 0

jo jo chápeme :)

 

new nick[22];
new ip[21];
GetPlayerName(playerid,nick,22);
GetPlayerIp(playerid, ip, 21);
if(!strcmp(nick, "Kamilko39", true))

 

myslíš niečo takéto ? :)

troška som sa nudil tak som vyfarbil :d :D :d

Link to comment
Share on other sites

  • 0

jo jo chápeme :)

 

new nick[22];

new ip[21];

GetPlayerName(playerid,nick,22);

GetPlayerIp(playerid, ip, 21);

if(!strcmp(nick, "Kamilko39", true))

 

myslíš niečo takéto ? :)

troška som sa nudil tak som vyfarbil :d :d :d

 

No už to ide.

Ale mal som to skoro rovnako len som mal meno v stoku ale toto funguje.

Ďik.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...