SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/04/2020, 10:40 AM   #1
Mahzen
Little Clucker
 
Join Date: Dec 2019
Posts: 44
Reputation: 0
Question INVALID_PLAYER_ID

Sometimes I get the error that the player was not found even though the player was in the game. It does this in all commands.

Command is running when the player logs in and out

Please Help

Code:
CMD:gotoplayer(playerid, params[])
{
	new ID, string[128];

    if(sscanf(params, "u", ID))
		return errormessage(playerid,"/gotoplayer -ID-");

	if(ID == INVALID_PLAYER_ID)
	    return errormessage(playerid,"No players found");

        new Float:x, Float:y, Float:z;
	GetPlayerPos(ID, x, y, z);

	SetPlayerPos(playerid, x + 2, y, z);
	
	SendClientMessage(playerid, COLOR_ADMIN, "Teleported");
	return 1;
}
Mahzen is offline   Reply With Quote
Old 14/04/2020, 10:42 AM   #2
Runn3R
Huge Clucker
 
Runn3R's Avatar
 
Join Date: Dec 2013
Location: Croatia, Split
Posts: 420
Reputation: 36
Default Re: INVALID_PLAYER_ID

You should check samp wiki as i can see that you are pretty new to this.


First off you didn't get the position of the other player and second of INVALID_PLAYER_ID is 65535 and there is no way that the ID can be that unless the player is not in-game.
Runn3R is offline   Reply With Quote
Old 14/04/2020, 10:46 AM   #3
Mahzen
Little Clucker
 
Join Date: Dec 2019
Posts: 44
Reputation: 0
Default Re: INVALID_PLAYER_ID

There is GetPlayerPos but I deleted it so that it is not a long issue. It also gives this error in all commands.
Mahzen is offline   Reply With Quote
Old 14/04/2020, 10:48 AM   #4
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,082
Reputation: 126
Default Re: INVALID_PLAYER_ID

You can also do it like this:

PHP Code:
CMD:gotoplayer(playeridparams[])
{
    new 
IDstring[128];

    if(
sscanf(params"u"ID))
        return 
errormessage(playerid,"/gotoplayer -ID-");

    if(!
IsPlayerConnected(ID))
        return 
errormessage(playerid,"No players found");

    new 
FloatPos[3];
    
GetPlayerPos(IDPos[0], Pos[1], Pos[2]);
    
SetPlayerPos(playeridPos[0] + 2Pos[1], Pos[2]);
    
    
SendClientMessage(playeridCOLOR_ADMIN"Teleported");
    return 
1;

Like Runn3r said, check the wiki.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 14/04/2020, 10:50 AM   #5
Mahzen
Little Clucker
 
Join Date: Dec 2019
Posts: 44
Reputation: 0
Default Re: INVALID_PLAYER_ID

If (! IsPlayerConnected (ID)) I also tried this command but it didn't work
Mahzen is offline   Reply With Quote
Old 14/04/2020, 10:52 AM   #6
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,082
Reputation: 126
Default Re: INVALID_PLAYER_ID

Then you should check if they are spawned I think.


PHP Code:
public OnPlayerSpawn(playerid)
{
    if(
GetPVarInt(playerid"is_connected")==0SetPVarInt(playerid"is_connected"1); // set the pvar to 1 for the check later
    
return 1;
}

IsPlayerConnectedEx(playerid)
{
    if (
IsPlayerConnected(playerid)&&GetPVarInt(playerid"is_connected")==1&&playerid!=INVALID_PLAYER_ID) return 1;
    return 
0;
}

CMD:gotoplayer(playeridparams[])
{
    new 
IDstring[128];

    if(
sscanf(params"u"ID))
        return 
errormessage(playerid,"/gotoplayer -ID-");

    if(!
IsPlayerConnectedEx(ID))
        return 
errormessage(playerid,"No players found");

    new 
FloatPos[3];
    
GetPlayerPos(IDPos[0], Pos[1], Pos[2]);
    
SetPlayerPos(playeridPos[0] + 2Pos[1], Pos[2]);
    
    
SendClientMessage(playeridCOLOR_ADMIN"Teleported");
    return 
1;

__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 14/04/2020, 11:02 AM   #7
Mahzen
Little Clucker
 
Join Date: Dec 2019
Posts: 44
Reputation: 0
Default Re: INVALID_PLAYER_ID

I will try this. Thank you
Mahzen is offline   Reply With Quote
Old 15/04/2020, 07:08 AM   #8
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: INVALID_PLAYER_ID

Update sscanf to 2.8.3
__________________
Calisthenics is offline   Reply With Quote
Old 15/04/2020, 09:28 AM   #9
DmitriyShift
Little Clucker
 
DmitriyShift's Avatar
 
Join Date: Jun 2019
Posts: 38
Reputation: 3
Default Re: INVALID_PLAYER_ID

Quote:
Originally Posted by Mahzen View Post
Sometimes I get the error that the player was not found even though the player was in the game. It does this in all commands.

Command is running when the player logs in and out

Please Help

Code:
CMD:gotoplayer(playerid, params[])
{
	new ID, string[128];

    if(sscanf(params, "u", ID))
		return errormessage(playerid,"/gotoplayer -ID-");

	if(ID == INVALID_PLAYER_ID)
	    return errormessage(playerid,"No players found");

        new Float:x, Float:y, Float:z;
	GetPlayerPos(ID, x, y, z);

	SetPlayerPos(playerid, x + 2, y, z);
	
	SendClientMessage(playerid, COLOR_ADMIN, "Teleported");
	return 1;
}



PHP Code:
CMD:gotoplayer(playeridparams[])
{
    new 
ID strval(params);

    if(
ID == INVALID_PLAYER_ID)) return errormessage(playerid,"/gotoplayer -ID-");
    if(!
IsPlayerConnected(ID)) return errormessage(playerid,"No players found");

    new 
FloatPos[3];
    
GetPlayerPos(IDPos[0], Pos[1], Pos[2]);
    
SetPlayerPos(playeridPos[0] + 2Pos[1], Pos[2]);

    
SendClientMessage(playeridCOLOR_ADMIN"Teleported");
    return 
true;

__________________
DmitriyShift is offline   Reply With Quote
Old 19/04/2020, 02:48 AM   #10
Mahzen
Little Clucker
 
Join Date: Dec 2019
Posts: 44
Reputation: 0
Default Re: INVALID_PLAYER_ID

Quote:
Originally Posted by Calisthenics View Post
Update sscanf to 2.8.3

I updated but still get the same error
Mahzen is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with INVALID_PLAYER_ID ,TomY' Scripting Help 1 01/08/2018 09:01 AM
!INVALID_PLAYER_ID SeanDenZYR Scripting Help 5 27/10/2017 08:30 AM
INVALID_PLAYER_ID Help +REP Ahmed21 Scripting Help 5 22/05/2017 07:50 PM
INVALID_PLAYER_ID russiany Help Archive 13 24/05/2009 09:32 AM


All times are GMT. The time now is 08:46 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.