SA-MP Forums Archive
Get ID with PlayerInfo - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get ID with PlayerInfo (/showthread.php?tid=599682)



Get ID with PlayerInfo - introx - 29.01.2016

Hi, ( Sorry for my english, i'm FR.. ! )

I have make a system for /nameoff with ID ( ex: Inconnu_18293 )

And i want retrieve the id of "unknow player" ( /nameoff player )

Код:
	else if(strcmp(cmd, "/inconnu", true) == 0)
	{
	    tmp = strtok(cmdtext, idx);
		new param1 = strval(tmp);
		if (!pack_isAdmin(playerid, 8))
			{SendClientMessage(playerid, COLOR_SERVER, noAcces); return 1;}
		if(!strlen(tmp))
			{SendClientMessage(playerid, COLOR_USAGE, "{FF6600}[Action]{99EEFF} /inconnu [ID inconnu]"); return 1;}
		for(i = MIN_PLAYERID; i < MAX_PLAYERS_CURRENT+1; i++)
		{
			if(param1 == idnomoff[i])
			{
 				new playername23[64], string23[150];
		  		GetPlayerName(i, playername23, sizeof(playername23));
		  		format(string23, sizeof(string23), "L'inconnu_%d est %s", param1, playername23);
		  		SendClientMessage(playerid, COLOR_WHITE, string23);
			}
			else
			{
		   		SendClientMessage(playerid, COLOR_WHITE, "Inconnu introuvable");
		   		return 1;
			}
		}
		return 1;
	}
My command returns always "Inconnu introuvable"

I am doing something wrong ..?

ty..


Re: Get ID with PlayerInfo - Tamy - 29.01.2016

Post the code of "/nameoff" command, it might not be saving the ID properly in the variable.


Re: Get ID with PlayerInfo - introx - 29.01.2016

Quote:

else if(strcmp(cmd, "/nomoff", true) == 0)
{
if(PlayerInfo[playerid][pLevel]<1
{SendClientMessage(playerid, COLOR_USAGE, "{FF6600}[Nom OFF]{99EEFF} Commande disponible a partir du niveau 3");return 1;}
new pln[MAX_PLAYER_NAME];
GetPlayerName(playerid,pln,sizeof(pln));
subcmd = strtok(cmdtext, idx);
if(CagouleUse[playerid]==0)
{
CagouleUse[playerid]=1;
check_nameTag(playerid);
idnomoff[playerid] = 10000+random(99999);
SendClientMessage(playerid, COLOR_WHITE, "Nomoff activй..");
player_refreshCagoule(playerid);
return 1;
}
else if(CagouleUse[playerid]==1)
{
CagouleUse[playerid]=0;
idnomoff[playerid] = 0;
check_nameTag(playerid);
Delete3DTextLabel(nom_off[playerid]);
SendClientMessage(playerid, COLOR_WHITE, "Nomoff desactivй..");
player_refreshCagoule(playerid);
return 1;
}
return 1;
}

/nomoff is Okey, because when i Talk in game

"format(showName, sizeof(showName), "Inconnu_%d dit",idnomoff[playerid], text);"

Sent -> Inconnu_92839 dit


Re: Get ID with PlayerInfo - Tamy - 29.01.2016

Here.

Код:
else if(strcmp(cmd, "/inconnu", true) == 0)
	{
	    tmp = strtok(cmdtext, idx);
		new param1 = strval(tmp);
                new f=0;
		if (!pack_isAdmin(playerid, 8))
			{SendClientMessage(playerid, COLOR_SERVER, noAcces); return 1;}
		if(!strlen(tmp))
			{SendClientMessage(playerid, COLOR_USAGE, "{FF6600}[Action]{99EEFF} /inconnu [ID inconnu]"); return 1;}
		for(i = MIN_PLAYERID; i < MAX_PLAYERS_CURRENT+1; i++)
		{
			if(param1 == idnomoff[i])
			{
 				new playername23[64], string23[150];
		  		GetPlayerName(i, playername23, sizeof(playername23));
		  		format(string23, sizeof(string23), "L'inconnu_%d est %s", param1, playername23);
		  		SendClientMessage(playerid, COLOR_WHITE, string23);
                                f=1;
			}
		}
		if(!f) SendClientMessage(playerid, COLOR_WHITE, "Inconnu introuvable");
		return 1;
	}



Re: Get ID with PlayerInfo - introx - 29.01.2016

It's ok ! thank's


Re: Get ID with PlayerInfo - introx - 29.01.2016

And..

i can get id inconnu for /kick ID, /give ID etc?

with ReturnUser ?


Re: Get ID with PlayerInfo - Tamy - 29.01.2016

Код:
stock getInconnuID(inconnueID)
{
    for(i = MIN_PLAYERID; i < MAX_PLAYERS_CURRENT+1; i++)
		{
			if(inconnuID == idnomoff[i])
			{
 				return inconnuID;
			}
		}
    }
And you can use this in /kick and /give as

Код:
    if(idnomoff[param1])
    {
        new i=getInconnuID(idnomoff[param1]);
        Kick(i);
     }
I hope this will help, report any error/issues, thanks.


Re: Get ID with PlayerInfo - introx - 29.01.2016

Quote:

if(idnomoff[param1])
{
new i=getInconnuID(idnomoff[param1]);
Kick(i);
}

This code does not seem right to me .. Why "if (id nomoff [param1])"
if I make / kick 28392, his will not know that it is a IDNOMOFF


Re: Get ID with PlayerInfo - Tamy - 29.01.2016

Then you can make it like this.

Код:
if(idnomoff[param1] > 10000 && CagouleUse[param1] == 1)
{
    new i=getInconnuID(idnomoff[param1]);
    Kick(i);
}
I found my mistake in getInconnuID function, fixed it.

Код:
stock getInconnuID(inconnueID)
{
    for(i = MIN_PLAYERID; i < MAX_PLAYERS_CURRENT+1; i++)
		{
			if(inconnuID == idnomoff[i])
			{
 				return i;
			}
		}
    }