On player connect, give player variables
#1

So I would like to give a player the pAdmin variable, which is under my enum. When the player with the name "JXF" would connect, I would like the server to give him the pAdmin variable with the level 1338. How would I manage to do that?

Here's my strcmp code:
Код:
forward NameJXF(playerid);
public NameJXF(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		new nume[24];
		GetPlayerName(playerid, nume, sizeof(nume));
		if((strcmp(nume, "JXF", true) == 0))
		{
			return 1;
		}
	}
	return 0;
}
EDIT:
I have tried to do the On player connect to give player variables with SetPVarInt
This is my code:
Код:
public OnPlayerConnect(playerid) 
{ 
    if(NameJXF(playerid)) 
	{
		new string[128];
		format(string, sizeof(string), "You have been given full administrator rights, master!");
		SCM(pid, COLOR_AQUA, string);
		SetPVarInt(playerid, Player[playerid][pAdmin], 1339);
	}
IT does compile, but it doesn't work properly. What is the issue here?
P.S I have never used setpvarint ever before.
Reply
#2

But anybudy who just connect with JXF tag he will get Admin level.
You must check that after player Logged properly.

Код:
public OnPlayerConnect(playerid)
{
	  if(strfind(GetName(playerid),"JXF", true) != -1)
	  { 		new string[128];
		format(string, sizeof(string), "You have been given full administrator rights, master!");
		SCM(pid, COLOR_AQUA, string);
		SetPVarInt(playerid, Player[playerid][pAdmin], 1339);
	}
}

GetName(playerid)
{
	new JName[MAX_PLAYER_NAME];
	GetPlayerName(playerid,JName,MAX_PLAYER_NAME);
	return JName;
}
Reply
#3

what does strfind and why would I not use strcmp instead?
I read the wiki and I don't understand it clearly.
Reply
#4

This will match both strings Like nume have JXFF1
so it will try match it with JXF you can see clearly both are different they are not matching.
if((strcmp(nume, "JXF", true) == 0))

about strfind it will find the JXF in the name of player.

wiki pedia.

(const string[],const sub[],bool:ignorecase=false,pos=0)

const string[] The string you want to search in (haystack).
here GetName(playerid) string You're searching in player name JXF

const sub[] The string you want to search for (needle).
JXF

strfind(GetName(playerid),"JXF",true)
Reply
#5

the SetPVarInt does not work.
enum:
Код:
enum PlayerInfo
{
	pAdmin
Код:
new Player[MAX_PLAYERS][PlayerInfo];
why doesnt the setpvarint work?
Reply
#6

use
PHP код:
Player[playerid][pAdmin] = 1339
Reply
#7

thank you oma, and also thank you bilal for the tips.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)