AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Logs Errors (https://forums.alliedmods.net/showthread.php?t=252259)

Decak 11-29-2014 05:18

Logs Errors
 
plugin_init:
Code:

RegisterHam(Ham_Spawn, "player", "spawnc")
spawnc:
Code:

public spawnc(id) {
    set_task(1.0, "ProveriMe", id)
    if(hpr[id]) {
    set_user_gravity(id, get_user_gravity(id)-0.3)
}
    if(smoke[id]) {
    give_item(id, "weapon_glock18")
    cs_set_weapon_ammo(find_ent_by_owner(-1, "weapon_glock18", id), 1)
    cs_set_user_bpammo( id, CSW_GLOCK18, 3 );
    return PLUGIN_HANDLED;
}
    if(glock[id]) {
    give_item(id, "weapon_glock18")
    cs_set_weapon_ammo(find_ent_by_owner(-1, "weapon_glock18", id), 1)
    cs_set_user_bpammo( id, CSW_GLOCK18, 0 );
}
}

Logs:
Code:

L 11/29/2014 - 10:58:43: [AMXX] Displaying debug trace (plugin "mod-fix.amxx")
L 11/29/2014 - 10:58:43: [AMXX] Run time error 10: native error (native "cs_set_weapon_ammo")
L 11/29/2014 - 10:58:43: [AMXX]    [0] 92r6935f.sma.p::spawnc (line 165)
L 11/29/2014 - 10:58:46: [FUN] Invalid player 14
L 11/29/2014 - 10:58:46: [AMXX] Displaying debug trace (plugin "mod-fix.amxx")
L 11/29/2014 - 10:58:46: [AMXX] Run time error 10: native error (native "get_user_gravity")
L 11/29/2014 - 10:58:46: [AMXX]    [0] 92r6935f.sma.p::spawnc (line 161)
L 11/29/2014 - 10:59:30: [CSTRIKE] Non-player entity 0 out of range

[/code]

Server is down every 3 days...Help?

simanovich 11-29-2014 05:27

Re: Logs Errors
 
PHP Code:

public plugin_init(){
    
// ...
    
RegisterHam(Ham_Spawn,"player","spawnc",1); // Post method - Called after a client spawns
    // ...
}

public 
spawnc(id){
    if (!
is_user_alive(id)) // Double check
        
return;

    
set_task(1.0"ProveriMe"id)

    if(
hpr[id])
        
set_user_gravity(idget_user_gravity(id) - 0.3);

    if(
smoke[id])
    {
        
cs_set_weapon_ammo(give_item(id"weapon_glock18"),1);
        
cs_set_user_bpammo(id,CSW_GLOCK18,);
    }

    else if(
glock[id])
    {
        
cs_set_weapon_ammo(give_item(id,"weapon_glock18"),1);
        
cs_set_user_bpammo(id,CSW_GLOCK18,0);
    }


Don't use find_ent_by_owner as the give_item native returns the item entity index.
Don't use pre method when you need post method.

Decak 11-29-2014 06:29

Re: Logs Errors
 
But logic is when user spawn, he is alive ? I will try this, thanks for this, but what is with gravity :) ? Server is down for this also :)

HamletEagle 11-29-2014 07:57

Re: Logs Errors
 
Quote:

Originally Posted by Decak (Post 2229389)
But logic is when user spawn, he is alive ? I will try this, thanks for this, but what is with gravity :) ? Server is down for this also :)

If you hook as pre, then the forward will be executed before the actual spawn.

RateX 11-29-2014 08:09

Re: Logs Errors
 
^Plus even after hook as post, sometimes the player will not yet alive.

HamletEagle 11-29-2014 08:16

Re: Logs Errors
 
Quote:

Originally Posted by RateX (Post 2229419)
^Plus event after hook as post, sometimes the player will not yet alive.

Sure, this is why we need to check is_user_alive on spawn.


All times are GMT -4. The time now is 17:42.

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