Raised This Month: $ Target: $400
 0% 

help with some dr vip plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slypire
Junior Member
Join Date: May 2013
Old 08-09-2013 , 18:35   help with some dr vip plugin
Reply With Quote #1

Hi guys, I'm using DeathRun VIP 3.1 bu TbagT, original thread https://forums.alliedmods.net/showthread.php?t=159675


I have tried to fix some errors what i get in my logs, but no way, so maybe someone of you guys know how to fix next:

Code:
L 08/10/2013 - 00:22:07: Info (map "deathrun_easy_professional_xXx") (file "addons/amxmodx/logs/error_20130810.log")
L 08/10/2013 - 00:22:07: Invalid CVAR pointer
L 08/10/2013 - 00:22:07: [AMXX] Displaying debug trace (plugin "DeathrunVip.amxx")
L 08/10/2013 - 00:22:07: [AMXX] Run time error 10: native error (native "get_pcvar_num")
L 08/10/2013 - 00:22:07: [AMXX]    [0] DeathrunVip.sma::plugin_precache (line 161)
L 08/10/2013 - 00:23:25: Invalid player id 128
L 08/10/2013 - 00:23:25: [AMXX] Displaying debug trace (plugin "DeathrunVip.amxx")
L 08/10/2013 - 00:23:25: [AMXX] Run time error 10: native error (native "get_user_flags")
L 08/10/2013 - 00:23:25: [AMXX]    [0] DeathrunVip.sma::event_deathmsg (line 381)
L 08/10/2013 - 00:23:25: [AMXX] Displaying debug trace (plugin "DeathrunVip.amxx")
L 08/10/2013 - 00:23:25: [AMXX] Run time error 4: index out of bounds 
L 08/10/2013 - 00:23:25: [AMXX]    [0] DeathrunVip.sma::Hook_Deathmessage (line 1169)
L 08/10/2013 - 00:25:25: Invalid player id 128
L 08/10/2013 - 00:25:25: [AMXX] Displaying debug trace (plugin "DeathrunVip.amxx")
L 08/10/2013 - 00:25:25: [AMXX] Run time error 10: native error (native "get_user_flags")
L 08/10/2013 - 00:25:25: [AMXX]    [0] DeathrunVip.sma::event_deathmsg (line 381)
L 08/10/2013 - 00:25:25: [AMXX] Displaying debug trace (plugin "DeathrunVip.amxx")
L 08/10/2013 - 00:25:25: [AMXX] Run time error 4: index out of bounds 
L 08/10/2013 - 00:25:25: [AMXX]    [0] DeathrunVip.sma::Hook_Deathmessage (line 1169)
Now lines..
PHP Code:
public plugin_precache()
{
    if(
get_pcvar_num(cvar_model) == 1)
    {
        
precache_model(VIP_MODEL)
    }
    if(
get_pcvar_num(cvar_connect) == 1)
    {
            
precache_sound(VIP_CONNECT)
    }
    if(
get_pcvar_num(cvar_popup) == 1)
    {
        
precache_sound(MENU_POPUP)
    }
    if(
get_pcvar_num(cvar_ok) == 1)
    {
        
precache_sound(MENU_OK)
    }
    
gCylinderSprite precache_model"sprites/shockwave.spr" );

161 is this: if(get_pcvar_num(cvar_model) == 1)


PHP Code:
public event_deathmsg()
{
    new 
victim read_data(2)
    new 
killer read_data(1)

    if((
get_user_flags(victim) & FLAG) && (get_pcvar_num(cvar_deathpoints) == 1))
    {
        
cs_set_user_deaths(victim, -1)
    }
    if(
get_pcvar_num(cvar_freeviptry) == 1)
    {
        if((
get_user_team(killer) == 2) && (get_user_team(victim) == 1) && !(get_user_flags(killer) & FLAG))
        {
            
VipPoints[killer] += 1;
        }
    }

381 is this: if((get_user_flags(victim) & FLAG) && (get_pcvar_num(cvar_deathpoints) == 1))


And last error is this
PHP Code:
public Hook_Deathmessage(id)
{
    new 
killer read_data);
    new 
victim read_data);

    if( 
killer == victim )
    {
        return 
PLUGIN_HANDLED;
    }
        
    
HasSpeedvictim ] = false;
    
    
set_user_maxspeedvictim0.0 );

    if(
RandomFunction[id] == 2)
    {
        
set_user_godmode(id1)
    }

    return 
PLUGIN_CONTINUE;

1169 is this: HasSpeed[ victim ] = false;



Thats it guys, I rly hope some of you know how to fix this, plugin working fine, but still makin me much logs, and i want to fix that, thanks in advance!
slypire is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-09-2013 , 19:28   Re: help with some dr vip plugin
Reply With Quote #2

You can't retrieve pcvars on plugin_precache() since precache occurs before plugin_init() where the cvars are registred as pcvars. You have to use regular cvars instead of pointers.
Also, there's no reason to use a pointer on a cvar that's used in precache anyway since it's only called once.

If this is a cvar that enables a function that are in need of the precached file MAKE SURE that the file was precached before starting this function or force precache on all files to make it easy. Otherwise you would require a mapchange just to enable any of the cvars. I'll give you some examples in a minute.

Here are some examples:
This is BAD!
This will cause problems:
Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 8", "", "");     register_cvar("test_cvar", "0", ADMIN_ADMIN); } public plugin_precache() {     if ( get_cvar_num("test_cvar") == 1 )         precache_generic("generic.file"); } public whatever_function(id) {     if ( get_cvar_num("test_cvar") == 1 )         whatever_native(id, "generic.file"); }
This is OK if you have a lot of files to precache:
You really have to know what you're doing if you're using this way.
It creates confusion and problems when people try to enable cvars since it requires a mapchange so that the required files can precache.
Code:
#include <amxmodx> new g_generic_file_was_precached = false; public plugin_init() {     register_plugin("Test Plugin 8", "", "");     register_cvar("test_cvar", "0", ADMIN_ADMIN); } public plugin_precache() {     if ( get_cvar_num("test_cvar") == 1 ) {         g_generic_file_was_precached = true;         precache_generic("generic.file");     } } public whatever_function(id) {     if ( get_cvar_num("test_cvar") == 1 && g_generic_file_was_precached )         whatever_native(id, "generic.file"); }
This is good for most ways:
Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 8", "", "");     register_cvar("test_cvar", "0", ADMIN_ADMIN); } public plugin_precache() {     precache_generic("generic.file"); } public whatever_function(id) {     if ( get_cvar_num("test_cvar") == 1 )         whatever_native(id, "generic.file"); }

In the event_deathmsg() the killer and victim are not always players. Therefor you must check if it actually is a player before you use the variables inside function that require players. The easiest way to check this is:
Code:
if ( ! is_user_connected(killer) || ! is_user_connected(victim) )    return;

Same thing goes for Hook_Deathmessage().
__________________

Last edited by Black Rose; 08-09-2013 at 19:52.
Black Rose is offline
slypire
Junior Member
Join Date: May 2013
Old 08-09-2013 , 19:50   Re: help with some dr vip plugin
Reply With Quote #3

Thanks a lot dude, I will try to fix that when I wake up tomorrow, if I dont make this fine, I hope you will help me to make this plugin fine because im just a beginner with amxx. Thanks again.

Last edited by slypire; 08-09-2013 at 19:53.
slypire is offline
slypire
Junior Member
Join Date: May 2013
Old 08-10-2013 , 05:07   Re: help with some dr vip plugin
Reply With Quote #4

Argh, I didn't fix this.
This is to advanced commands for beginner like me.
If anybody can fix this, please attach .sma file.

EDIT: Sorry for double post :S

Last edited by slypire; 08-10-2013 at 05:07.
slypire is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-12-2013 , 11:29   Re: help with some dr vip plugin
Reply With Quote #5

This fixes the precache issue in the most easy way:
Code:
public plugin_precache() {     precache_model(VIP_MODEL)     precache_sound(VIP_CONNECT)     precache_sound(MENU_POPUP)     precache_sound(MENU_OK)     gCylinderSprite = precache_model( "sprites/shockwave.spr" ); }

You have 2 DeathMsg hooks that you can combine.

First you remove this:
Code:
public Hook_Deathmessage(id) {     new killer = read_data( 1 );     new victim = read_data( 2 );     if( killer == victim )     {         return PLUGIN_HANDLED;     }             HasSpeed[ victim ] = false;         set_user_maxspeed( victim, 0.0 );     if(RandomFunction[id] == 2)     {         set_user_godmode(id, 1)     }     return PLUGIN_CONTINUE; }
and this
Code:
register_event( "DeathMsg", "Hook_Deathmessage", "a" );

And then you edit event_deathmsg() to this:
Code:
public event_deathmsg() {     new victim = read_data(2)     new killer = read_data(1)         if ( ! is_user_connected(victim) )         return      if((get_user_flags(victim) & FLAG) && (get_pcvar_num(cvar_deathpoints) == 1))     {         cs_set_user_deaths(victim, -1)     }     if(is_user_connected(killer) && get_pcvar_num(cvar_freeviptry) == 1)     {         if((get_user_team(killer) == 2) && (get_user_team(victim) == 1) && !(get_user_flags(killer) & FLAG))         {             VipPoints[killer] += 1;         }     }         HasSpeed[ victim ] = false;         set_user_maxspeed( victim, 0.0 );     if(RandomFunction[killer/*?*/] == 2)     {         set_user_godmode(killer/*?*/, 1)     } }

Come back if you have further errors
__________________
Black Rose is offline
slypire
Junior Member
Join Date: May 2013
Old 08-13-2013 , 04:02   Re: help with some dr vip plugin
Reply With Quote #6

Thank you Black Rose, everything is ok now
Thanks one more time.
slypire 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 15:45.


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