Raised This Month: $ Target: $400
 0% 

Invalid player error I need help with.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raa
Senior Member
Join Date: Oct 2005
Old 04-29-2007 , 16:11   Invalid player error I need help with.
Reply With Quote #1

For a few months now I've been trying to figure out why I get this error.

Code:
[FUN] Invalid player #   <---------  each error is different number(player index)
L 04/28/2007 - 23:09:06: [AMXX] Displaying debug trace (plugin "respawn_auto.amxx")
L 04/28/2007 - 23:09:06: [AMXX] Run time error 10: native error (native "set_user_godmode")
L 04/28/2007 - 23:09:06: [AMXX]    [0] respawn_reinforce.sma::no_god (line 637)
here's the related code

Code:
public no_god(id)     {     set_user_godmode(id)   //<----  LINE 637     set_user_rendering(id,kRenderFxNone,255,255,255,kRenderNormal,255) }


Code:
public actual_revive(parm[])     {     new id = parm[0], a = parm[1]     if (is_user_connected(id)) {         spawn(id)         if (get_cvar_num(CVAR_GOD_TIME) > 0)             {             set_task( 0.8, "postspawn", id)             set_user_godmode(id, 1)             set_task(get_cvar_float(CVAR_GOD_TIME), "no_god", id)             set_user_rendering(id,kRenderFxGlowShell,0,225,0,kRenderNormal,25)         }         if(a==0)             get_user_origin(id, SOrigin[id])         else             set_user_origin(id, SOrigin[id])     } }

From all that I have found relating to this error a is_user_connected(id) check was advised. I tried that.. still no luck
__________________
raa is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-29-2007 , 16:56   Re: Invalid player error I need help with.
Reply With Quote #2

Code:
public no_god(id)     {     /**      * If your going to use a set_task with dealing with players      * then your going to have to make sure that they are connected      * the task is completed especially with natives that required the      * the client to be connected.      */     if(!is_user_connected(id))         return;     set_user_godmode(id)   //<----  LINE 637     set_user_rendering(id,kRenderFxNone,255,255,255,kRenderNormal,255) }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
MadMaurice
Junior Member
Join Date: Apr 2007
Old 05-02-2007 , 06:50   Re: Invalid player error I need help with.
Reply With Quote #3

sry teame06 buts its not that hte player isn't on the server but you should look at the line:

set_task(get_cvar_float(CVAR_GOD_TIME), "no_god", id)
the third parameter is the id of the task not the parameter that is givent to "no_god"

i would change this one into

set_task(get_cvar_float(CVAR_GOD_TIME), "no_god",57, id)
or another number than 57

if i helped plz submit +karma
MadMaurice is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-02-2007 , 14:53   Re: Invalid player error I need help with.
Reply With Quote #4

Quote:
Originally Posted by MadMaurice View Post
sry teame06 buts its not that hte player isn't on the server but you should look at the line:

set_task(get_cvar_float(CVAR_GOD_TIME), "no_god", id)
the third parameter is the id of the task not the parameter that is givent to "no_god"

i would change this one into

set_task(get_cvar_float(CVAR_GOD_TIME), "no_god",57, id)
or another number than 57

if i helped plz submit +karma
You are wrong. The player can be disconnect from the server while the set_task is running. When the task is execute and set_user_mode native is used it throw a runtime error of invalid player because of a non-existing connected player. And this is what is happening not what you are thinking.

Code:
set_task(get_cvar_float(CVAR_GOD_TIME), "no_god", id)
There is no problem using that line like that. There is no problem with passing the player id in the task id.

[quote="MadMaurice"]
set_task(get_cvar_float(CVAR_GOD_TIME), "no_god",57, id)
or another number than 57[quote]

Secondly of all you used the 4th parmeter wrong too. The 4th parameter is an array you pass.

So you have to do
Code:
new something[2]; something[0] = id; set_task(..., ..., ..., ..., something, 2);

Also if you you were going to remove the task later. You would do a unique task.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
raa
Senior Member
Join Date: Oct 2005
Old 05-02-2007 , 16:34   Re: Invalid player error I need help with.
Reply With Quote #5

well at anyrate, adding in the is_connected check within the no_god function seems to have done the trick.

thanks a lot both of you for giving your input. very much appreciated.
__________________
raa is offline
MadMaurice
Junior Member
Join Date: Apr 2007
Old 05-03-2007 , 09:45   Re: Invalid player error I need help with.
Reply With Quote #6

@teame

thats right they could disconnect but this is not what the error is telling about.if you had looked at the errors you would see that theres an error everywhere where the var id is used. he didn't gave it to the nogod function

ps.: i made many plugins which worked with given the id to the parm array

Last edited by MadMaurice; 05-03-2007 at 09:48.
MadMaurice is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-03-2007 , 11:14   Re: Invalid player error I need help with.
Reply With Quote #7

@ MadMaurice

The problem is that his set_task is still correct usage. Nothing wrong with the var id he used. Everything in his set_task is still correct usage.

Code:
#define CHECK_PLAYER(x) \
	if (x < 1 || x > gpGlobals->maxClients) { \
		MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
		return 0; \
	} else { \
		if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
			MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
			return 0; \
		} \
	}
This is the error checking from the fun module for all it player natives. It gave him the error "Invalid player x". So his id was still in range otherwise it would of thrown a "Player out of range error". He said the line the error threw was on line 637 was set_user_godmode. It thrown a "Invalid Player x" because the player wasn't connected to the server.

This is the last time i'm saying it. Nothing is wrong with this set_task
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 05-03-2007 , 11:24   Re: Invalid player error I need help with.
Reply With Quote #8

MadMaurice: You are incorrect.

Raa is passing the player's id in as the task id. There's nothing wrong with that and it's a shortcut that many people use when appropriate.
__________________
Brad is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 05-03-2007 , 11:28   Re: Invalid player error I need help with.
Reply With Quote #9

Quote:
Originally Posted by teame06 View Post
@ MadMaurice

The problem is that his set_task is still correct usage. Nothing wrong with the var id he used. Everything in his set_task is still correct usage.

Code:
#define CHECK_PLAYER(x) \
	if (x < 1 || x > gpGlobals->maxClients) { \
		MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
		return 0; \
	} else { \
		if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
			MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
			return 0; \
		} \
	}
This is the error checking from the fun module for all it player natives. It gave him the error "Invalid player x". So his id was still in range otherwise it would of thrown a "Player out of range error". He said the line the error threw was on line 637 was set_user_godmode. It thrown a "Invalid Player x" because the player wasn't connected to the server.

This is the last time i'm saying it. Nothing is wrong with this set_task
OHHHHHHHHHHHHHHHHHHHH

MADMAURICE GOT OWNED IN THE GRILL
sawce is offline
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

Forum Jump


All times are GMT -4. The time now is 06:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode