AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What means that error? (https://forums.alliedmods.net/showthread.php?t=147065)

~Ice*shOt 01-05-2011 02:04

What means that error?
 
Topic^
Quote:

L 01/04/2011 - 23:29:13: [FUN] Player out of range (0)
L 01/04/2011 - 23:29:13: [AMXX] Displaying debug trace (plugin "zombies_strike.amxx")
L 01/04/2011 - 23:29:13: [AMXX] Run time error 10: native error (native "set_user_health")
L 01/04/2011 - 23:29:13: [AMXX] [0] zombies_strike.sma::First_Infected (line 452)

drekes 01-05-2011 02:13

Re: What means that error?
 
post your code or at least the First_Infected function.
You're setting health on an invalid player id.

~Ice*shOt 01-05-2011 02:52

Re: What means that error?
 
PHP Code:

public First_Infected(id)
{
       
g_zombie[id] = true
       FirstInfected
[id] = true

    
static Name[32]
    
get_user_name(idNamecharsmax(Name))
            
    
set_hudmessage(17900, -1.00.2820.021.00.010.110)
        
show_hudmessage(0"Beware! %s is First Infected!"Name)

    
set_user_health(idget_pcvar_num(first_zombie_health))
    
set_user_gravity(idget_pcvar_float(first_zombie_gravity) / 800)

    if (!
cs_get_user_nvg(id))
        
cs_set_user_nvg(id)
        
    if (
get_pcvar_num(zm_autonvg))
        
set_task(0.2"Task_NVG"TASKID_NVG id)

    
set_task(0.1"ShowHealth"id""0"b")

    
cs_set_user_model(idZombie_Models[random(sizeof Zombie_Models)])



drekes 01-05-2011 03:28

Re: What means that error?
 
Check the code that calls this function, and see if id == 0

~Ice*shOt 01-05-2011 03:47

Re: What means that error?
 
this is a call function
PHP Code:

set_task(10.0"First_Infected"

if i do that
PHP Code:

set_task(10.0"First_Infected"id

it's true?

GXLZPGX 01-05-2011 04:34

Re: What means that error?
 
Quote:

Originally Posted by ~Ice*shOt (Post 1386382)
this is a call function
PHP Code:

set_task(10.0"First_Infected"

if i do that
PHP Code:

set_task(10.0"First_Infected"id

it's true?

Yes. The first one is calling the function "First_Infected" without a given index, and without an index, I'm gonna take a shot in the dark and say it choses 0 as the index, and 0 isn't a valid player index. The second one though, provides an index.

drekes 01-05-2011 05:04

Re: What means that error?
 
Quote:

Originally Posted by GXLZPGX (Post 1386397)
Yes. The first one is calling the function "First_Infected" without a given index, and without an index, I'm gonna take a shot in the dark and say it choses 0 as the index, and 0 isn't a valid player index. The second one though, provides an index.

I'd like to add that id can be 0 too, that depends on how you use it.

PHP Code:

new id;
set_task(1.0"First_Infected"id); 

This will call your function, but id passed in the params will be 0.

PHP Code:

public client_putinserver(id)
    
set_task(1.0"First_Infected"id); 

This will call the function with id being the id of the player that entered the server.

To check if a variable contains a player id, you can use this:
PHP Code:

// Global
#define IsPlayer(%1)    (1 <= %1 <= g_iMaxPlayers)
new g_iMaxPlayers;

public 
plugin_init()
    
g_iMaxPlayers get_maxplayers();

SomeFunc(id)
{
    if(
IsPlayer(id))
        
// It is a  player id, you might wanna check if he's alive and stuff depending on what you are doing here.



~Ice*shOt 01-05-2011 05:20

Re: What means that error?
 
OK. Thanks :)

MyDooMJr 01-05-2011 09:42

Re: What means that error?
 
Just one thing are u using #include <fun> ??

drekes 01-05-2011 10:09

Re: What means that error?
 
Quote:

Originally Posted by MyDooMJr (Post 1386523)
Just one thing are u using #include <fun> ??

He must or the plugin won't compile


All times are GMT -4. The time now is 01:58.

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