AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with some dr vip plugin (https://forums.alliedmods.net/showthread.php?t=223099)

slypire 08-09-2013 18:35

help with some dr vip plugin
 
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!

Black Rose 08-09-2013 19:28

Re: help with some dr vip plugin
 
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().

slypire 08-09-2013 19:50

Re: help with some dr vip plugin
 
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.

slypire 08-10-2013 05:07

Re: help with some dr vip plugin
 
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

Black Rose 08-12-2013 11:29

Re: help with some dr vip plugin
 
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

slypire 08-13-2013 04:02

Re: help with some dr vip plugin
 
Thank you Black Rose, everything is ok now :)
Thanks one more time.


All times are GMT -4. The time now is 15:45.

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