AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invalid player error I need help with. (https://forums.alliedmods.net/showthread.php?t=54593)

raa 04-29-2007 16:11

Invalid player error I need help with.
 
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

teame06 04-29-2007 16:56

Re: Invalid player error I need help with.
 
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) }

MadMaurice 05-02-2007 06:50

Re: Invalid player error I need help with.
 
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

teame06 05-02-2007 14:53

Re: Invalid player error I need help with.
 
Quote:

Originally Posted by MadMaurice (Post 472409)
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.

raa 05-02-2007 16:34

Re: Invalid player error I need help with.
 
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.

MadMaurice 05-03-2007 09:45

Re: Invalid player error I need help with.
 
@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

teame06 05-03-2007 11:14

Re: Invalid player error I need help with.
 
@ 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

Brad 05-03-2007 11:24

Re: Invalid player error I need help with.
 
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.

sawce 05-03-2007 11:28

Re: Invalid player error I need help with.
 
Quote:

Originally Posted by teame06 (Post 472920)
@ 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


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

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