Raised This Month: $ Target: $400
 0% 

Some weird errors (please help)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 08-29-2009 , 20:22   Some weird errors (please help)
Reply With Quote #1

I'm trying to update my new plugin Adrenaline Rush. I'm currently testing it right now and I keep on getting these errors when I run debug mode:

Code:
L 08/29/2009 - 20:17:04: [CSTRIKE] Player out of range (0)
L 08/29/2009 - 20:17:04: [AMXX] Displaying debug trace (plugin "adrenaline_rush(24).amxx")
L 08/29/2009 - 20:17:04: [AMXX] Run time error 10: native error (native "cs_get_user_money")
L 08/29/2009 - 20:17:04: [AMXX]    [0] phpaTu1HV.sma::eventDeathHyper (line 238)
L 08/29/2009 - 20:17:04: [AMXX]    [1] phpaTu1HV.sma::eventHandleHyper (line 227)
L 08/29/2009 - 20:17:04: [AMXX]    [2] phpaTu1HV.sma::rushMenu (line 158)
Can anyone help me fix my problems?

Line 238:
PHP Code:
rushCash cs_get_user_money(killer); 
Line 227:
PHP Code:
eventDeathHyper() 
Line 158:
PHP Code:
eventHandleHyper(id
Full code:
PHP Code:
/*
    Adrenaline Rush
    Version 1.1
    BOYSplayCS 

    Information about this plugin can be found at:
    http://forums.alliedmods.net/showthread.php?t=102051

    Thank you to the following people for helping:
    None yet

*/

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define PLUGIN "Adrenaline Rush"
#define VERSION "1.1"
#define AUTHOR "BOYSplayCS"

const FADE_IN 0x0000;
const 
KEYS MENU_KEY_1|MENU_KEY_2;

new 
playerControl[33];
new 
playerAbility[33];

new 
g_nMsgScreenFade;

new 
rushTogglerushHealthrushScreenrushRedrushSpeedrushSoundrushGravrushMenu1;
new 
rushHyperMoney;

new 
boolfreezetime;
new 
boolrestart;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("endGame"2"1=Round_End");
    
register_logevent("startGame"2"1=Round_Start");
    
    
register_event("TextMsg""restartGame""a""2=#Game_will_restart_in");
    
register_event("TextMsg""restartGame""a""2=#Game_Commencing");
    
    
register_event("Damage""eventDamage""b");
    
register_event("CurWeapon""eventWeapon""be");
    
register_event("DeathMsg""eventDeath""a");
    
register_event("DeathMsg""eventDeathHyper""a");
    
    
register_menucmd(register_menuid("Mode Selection Menu"), KEYS"rushMenu");
    
    
g_nMsgScreenFade get_user_msgid("ScreenFade");
    
    
rushToggle register_cvar("ar_activate""1");
    
rushHealth register_cvar("ar_health""25");
    
rushScreen register_cvar("ar_screen_activate""1");
    
rushRed register_cvar("ar_screen_red""200");
    
rushSpeed register_cvar("ar_speed""350.0");
    
rushGrav register_cvar("ar_gravity""0.6");
    
rushSound register_cvar("ar_sound""1");
    
    
rushMenu1 register_cvar("ar_menu""1");
    
rushHyperMoney register_cvar("ar_hyper_money""500");
    
    
register_dictionary("adrenaline_rush.txt");
}

public 
plugin_precache()
{
    
precache_sound("player/pl_die1.wav");
}

public 
endGame()
{
    new 
players[32], num;
    
get_players(playersnum"h");
    
    for (new 
0numi++)
    {
        
playerAbility[players[i]] = 0;
        
set_user_maxspeed(players[i], 320.0);
        
set_user_gravity(players[i], 1.0);
    }
    
    
freezetime true;
}

public 
restartGame()
{
    
restart true;
    
    new 
players[32], num;
    
get_players(playersnum"h");
    
    for (new 
0numi++)
    {
        
playerAbility[players[i]] = 0;
        
set_user_maxspeed(players[i], 320.0);
        
set_user_gravity(players[i], 1.0);
    }
}

public 
startGame()
{
    if (
restart && get_pcvar_num(rushToggle))
    {
        
restart false;
        
        new 
players[32], num;
        
get_players(playersnum"h");
        
        for(new 
0numi++)
        {
            
playerAbility[players[i]] = 0;
            
set_user_maxspeed(players[i], 320.0);
            
set_user_gravity(players[i], 1.0);
        }
    }
    
    
freezetime false;
}

public 
eventDamage(id)
{
    if (!
get_pcvar_num(rushToggle))
    return 
PLUGIN_CONTINUE;
    
    if (
is_user_alive(id) && get_pcvar_num(rushSound) && get_user_health(id) <= get_pcvar_num(rushHealth))
    {
        
client_cmd(id"spk player/pl_die1.wav");
        
eventHandleMain(id)
    }
    return 
PLUGIN_CONTINUE;
}

public 
eventHandleMain(id)
{
    if (
get_pcvar_num(rushMenu1))
    {
        new 
szBuffer[300], iLen;
        
iLen formatex(szBuffercharsmax(szBuffer), "\d%L^n"id"MENU_TITLE");
        
iLen += formatex(szBuffer[iLen], charsmax(szBuffer) - iLen"\r%L^n^n"id"MENU_INFO");
        
iLen += formatex(szBuffer[iLen], charsmax(szBuffer) - iLen"\y(1)\w%L^n"id"MENU_HYPER");
        
iLen += formatex(szBuffer[iLen], charsmax(szBuffer) - iLen"\y(2)\w%L^n"id"MENU_NORMAL");
        
show_menu(idKEYSszBuffer);
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
rushMenu(idkey)
{
    switch(
key)
    {
        case 
0:
        {
            
eventHandleHyper(id)
            return 
PLUGIN_HANDLED;
        }
        case 
1:
        {
            
eventHandle(id)
            return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_HANDLED
}

public 
eventDeath()
{
    if (
get_pcvar_num(rushToggle) && !restart)
    {
        new 
id read_data(1);
        
// new target = read_data(2);
        
        
set_user_maxspeed(id320.0);
        
set_user_gravity(id1.0);
    }
}

public 
client_connect(id)
{
    
playerControl[id] = 0;
    
playerAbility[id] = 0;
    
    
// return PLUGIN_HANDLED;
}

public 
client_disconnect(id)
{
    
playerControl[id] = 0;
    
playerAbility[id] = 0;
    
    
// return PLUGIN_HANDLED;
}

public 
eventHandleHyper(id)
{
    
    new 
name[32];
    
get_user_name(idname31);
    
    
set_user_maxspeed(idget_pcvar_float(rushSpeed));
    
set_user_gravity(idget_pcvar_float(rushGrav) / 800);
    
playerControl[id] = 1;
    
playerAbility[id] = 1;
    
    
set_hudmessage(25525500.900.0216.030.0);
    
show_hudmessage(id"%L"id"MSG_WARN");
    
    
client_print(idprint_chat"%L"id"MSG_ALERT_HYPER"name);
    
    if (!
get_pcvar_num(rushScreen))
    return 
PLUGIN_CONTINUE;
    
    
message_begin(MSG_ONE_UNRELIABLEg_nMsgScreenFade, {000}, id);
    
write_short(12 << 12);        
    
write_short(12 << 12);        
    
write_short(FADE_IN);        
    
write_byte(get_pcvar_num(rushRed));        
    
write_byte(0);        
    
write_byte(0);        
    
write_byte(127);
    
message_end();
    
    
eventDeathHyper()
    
    return 
PLUGIN_HANDLED;
}

public 
eventDeathHyper()
{
    new 
killer read_data(1);
    new 
victim read_data(2);
    
    new 
rushCash;
    
rushCash cs_get_user_money(killer);
        
    
cs_set_user_money(killerrushCash get_pcvar_num(rushHyperMoney));
    
client_print(killerprint_chat"%L"killer"MSG_HYPER"victimget_pcvar_num(rushHyperMoney));    
}

public 
eventHandle(id)
{
    new 
name[32];
    
get_user_name(idname31);
    
    
set_user_maxspeed(idget_pcvar_float(rushSpeed));
    
set_user_gravity(idget_pcvar_float(rushGrav) / 800);
    
playerControl[id] = 1;
    
playerAbility[id] = 1;
    
    
set_hudmessage(25525500.900.0216.030.0);
    
show_hudmessage(id"%L"id"MSG_WARN");
    
    
client_print(idprint_chat"%L"id"MSG_ALERT"name);
    
    if (!
get_pcvar_num(rushScreen))
    return 
PLUGIN_CONTINUE;
    
    
message_begin(MSG_ONE_UNRELIABLEg_nMsgScreenFade, {000}, id);
    
write_short(12 << 12);        
    
write_short(12 << 12);        
    
write_short(FADE_IN);        
    
write_byte(get_pcvar_num(rushRed));        
    
write_byte(0);        
    
write_byte(0);        
    
write_byte(127);
    
message_end();
    
    return 
PLUGIN_HANDLED;
}

public 
eventWeapon(id)
{    
    if (
get_pcvar_num(rushToggle) && !freezetime)
    {
        if (
playerAbility[id] == && playerAbility[id] == 1)
        {
            
// client_cmd(id, "cl_forwardspeed 400;cl_backspeed 400;cl_sidespeed 400");
            
            
new Floatspeed get_pcvar_float(rushSpeed);
            new 
Floatgravity get_pcvar_float(rushGrav);
            
            
set_user_maxspeed(idspeed);
            
set_user_gravity(idgravity 800);
        }
    }

BOYSplayCS is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 08-29-2009 , 20:23   Re: Some weird errors (please help)
Reply With Quote #2

The errors happen when I select "Adrenaline Hyper Mode" in the menu.
BOYSplayCS is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 08-29-2009 , 20:30   Re: Some weird errors (please help)
Reply With Quote #3

You are calling a function that expects to be called as the result of an event:
PHP Code:
    register_event("DeathMsg""eventDeathHyper""a"); 
from another function. So, read_data() won't work on it. Still, 0 can be an attacker so you should check if the attacker is a valid player. Ignore otherwise.
__________________
joaquimandrade is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 08-30-2009 , 11:13   Re: Some weird errors (please help)
Reply With Quote #4

Edit: Stupidity removed.

Last edited by BOYSplayCS; 08-30-2009 at 11:21.
BOYSplayCS is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 08-29-2009 , 20:31   Re: Some weird errors (please help)
Reply With Quote #5

Would 0 be considered the killer?
BOYSplayCS is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 08-29-2009 , 20:33   Re: Some weird errors (please help)
Reply With Quote #6

When a player commits suicide (not every kind of it), the attacker is considered to be 0 (worldspawn)
__________________
joaquimandrade is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 08-29-2009 , 20:37   Re: Some weird errors (please help)
Reply With Quote #7

I just tried replacing all the "killer" with "0" and it still displays the same errors, I have no clue what to do from here. I've tested it 27(literally) different times. If it isn't too much trouble, could you provide me a code that could fix this annoying shit?
BOYSplayCS is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 08-29-2009 , 20:49   Re: Some weird errors (please help)
Reply With Quote #8

PHP Code:
if(!(<= killer <= 32))
    return ... 
__________________
joaquimandrade is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 08-29-2009 , 20:57   Re: Some weird errors (please help)
Reply With Quote #9

Thank you, joa - it works now!

I have one more question, whenever my health reaches the cvar, it displays the menu correctly and all. Although, once I'm done choosing my option, if I get damaged again, the menu appears - how do I stop this from happening?
BOYSplayCS is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 08-29-2009 , 21:02   Re: Some weird errors (please help)
Reply With Quote #10

Quote:
Originally Posted by BOYSplayCS View Post
Thank you, joa - it works now!

I have one more question, whenever my health reaches the cvar, it displays the menu correctly and all. Although, once I'm done choosing my option, if I get damaged again, the menu appears - how do I stop this from happening?
Make a global variable 33 cells sized (bool tagged) and:

on player spawn set the position "id" to false.
on menu display check its value on position "id". If false, continue and make it true.
__________________
joaquimandrade 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:02.


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