Raised This Month: $ Target: $400
 0% 

Logs Errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Decak
Senior Member
Join Date: Sep 2012
Old 11-29-2014 , 05:18   Logs Errors
Reply With Quote #1

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?
Decak is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 11-29-2014 , 05:27   Re: Logs Errors
Reply With Quote #2

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.
__________________
simanovich is offline
Decak
Senior Member
Join Date: Sep 2012
Old 11-29-2014 , 06:29   Re: Logs Errors
Reply With Quote #3

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
Decak is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-29-2014 , 07:57   Re: Logs Errors
Reply With Quote #4

Quote:
Originally Posted by Decak View Post
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.
__________________
HamletEagle is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 11-29-2014 , 08:09   Re: Logs Errors
Reply With Quote #5

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

Last edited by RateX; 11-29-2014 at 08:17.
RateX is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-29-2014 , 08:16   Re: Logs Errors
Reply With Quote #6

Quote:
Originally Posted by RateX View Post
^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.
__________________
HamletEagle is offline
Reply



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 17:42.


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