Raised This Month: $51 Target: $400
 12% 

API Scripting Help Code error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 02-07-2012 , 11:08   Code error
Reply With Quote #1

Why do i get this error?
PS: This is an eddited version of the inf. grenade.

Code:
L 02/07/2012 - 15:28:19: [ZP] Invalid Player (15)
L 02/07/2012 - 15:28:19: [AMXX] Displaying debug trace (plugin "zp50_item_infection_bomb.amxx")
L 02/07/2012 - 15:28:19: [AMXX] Run time error 10: native error (native "zp_core_infect")
L 02/07/2012 - 15:28:19: [AMXX]    [0] zp50_item_infection_bomb.sma::infection_explode (line 317)
L 02/07/2012 - 15:28:19: [AMXX]    [1] zp50_item_infection_bomb.sma::fw_ThinkGrenade (line 258)
Line 258

PHP Code:
public fw_ThinkGrenade(entity)

{
    
// Invalid entity
    
if (!pev_valid(entity)) return HAM_IGNORED;
    
    
// Get damage time of grenade
    
static Float:dmgtime
    pev
(entitypev_dmgtimedmgtime)
    
    
// Check if it's time to go off
    
if (dmgtime get_gametime())
        return 
HAM_IGNORED;
    
    
// Check if it's one of our custom nades
    
switch (pev(entityPEV_NADE_TYPE))
    {
        case 
NADE_TYPE_INFECTION// Infection Bomb
        
{
258 -->            infection_explode(entity)
            return 
HAM_SUPERCEDE;
        }
    }
    
    return 
HAM_IGNORED;

Line 317

PHP Code:
// Infection Bomb Explosion
infection_explode(ent)
{
    
// Round ended
    
if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Get origin
    
static Float:origin[3]
    
pev(entpev_originorigin)
    
    
// Make the explosion
    
create_blast(origin)
    
    
// Infection nade explode sound
    
static sound[SOUND_MAX_LENGTH]
    
ArrayGetString(g_sound_grenade_infect_exploderandom_num(0ArraySize(g_sound_grenade_infect_explode) - 1), soundcharsmax(sound))
    
emit_sound(entCHAN_WEAPONsound1.0ATTN_NORM0PITCH_NORM)
    
    
// Get attacker
    
new attacker pev(entpev_owner)
    
    
// Infection bomb owner disconnected or not zombie anymore?
    
if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Collisions
    
new victim = -1
    
    
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginNADE_EXPLOSION_RADIUS)) != 0)
    {
        
// Only effect alive humans
        
if (!is_user_alive(victim) || zp_core_is_zombie(victim))
            continue;
        
        
// Last human is killed
        
if (zp_core_get_human_count() == 1)
        {
            
ExecuteHamB(Ham_Killedvictimattacker0)
            continue;
        }
        
        
// Turn into zombie
317 -->        zp_core_infect(victimattacker)
        
        
// Victim's sound
        
ArrayGetString(g_sound_grenade_infect_playerrandom_num(0ArraySize(g_sound_grenade_infect_player) - 1), soundcharsmax(sound))
        
emit_sound(victimCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
    }
    
    
// Get rid of the grenade
    
engfunc(EngFunc_RemoveEntityent)

Attached Files
File Type: sma Get Plugin or Get Source (zp50_item_infection_bomb.sma - 632 views - 12.8 KB)
__________________

Last edited by H.RED.ZONE; 02-07-2012 at 11:09.
H.RED.ZONE is offline
Snaker beatter
Veteran Member
Join Date: Sep 2011
Location: Manila, Philippines
Old 02-07-2012 , 11:16   Re: Code error
Reply With Quote #2

PHP Code:
// Infection Bomb Explosion
infection_explode(ent)

->

PHP Code:
// Infection Bomb Explosion
infection_explode(ent)
{
    if (!
pev_valid(ent)
    {
        
engfunc(EngFunc_RemoveEntityent)
        return;
    } 
__________________

Last edited by Snaker beatter; 02-07-2012 at 11:16.
Snaker beatter is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 02-07-2012 , 11:24   Re: Code error
Reply With Quote #3

Quote:
Originally Posted by Snaker beatter View Post
PHP Code:
// Infection Bomb Explosion
infection_explode(ent)

->

PHP Code:
// Infection Bomb Explosion
infection_explode(ent)
{
    if (!
pev_valid(ent)
    {
        
engfunc(EngFunc_RemoveEntityent)
        return;
    } 
Then like this?
PHP Code:
// Infection Bomb Explosion
infection_explode(ent)
{
    if (!
pev_valid(ent)
    {
        
engfunc(EngFunc_RemoveEntityent)
    return;
    }
    
// Round ended
    
if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Get origin
    
static Float:origin[3]
    
pev(entpev_originorigin)
    
    
// Make the explosion
    
create_blast(origin)
    
    
// Infection nade explode sound
    
static sound[SOUND_MAX_LENGTH]
    
ArrayGetString(g_sound_grenade_infect_exploderandom_num(0ArraySize(g_sound_grenade_infect_explode) - 1), soundcharsmax(sound))
    
emit_sound(entCHAN_WEAPONsound1.0ATTN_NORM0PITCH_NORM)
    
    
// Get attacker
    
new attacker pev(entpev_owner)
    
    
// Infection bomb owner disconnected or not zombie anymore?
    
if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Collisions
    
new victim = -1
    
    
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginNADE_EXPLOSION_RADIUS)) != 0)
    {
        
// Only effect alive humans
        
if (!is_user_alive(victim) || zp_core_is_zombie(victim))
            continue;
        
        
// Last human is killed
        
if (zp_core_get_human_count() == 1)
        {
            
ExecuteHamB(Ham_Killedvictimattacker0)
            continue;
        }
        
        
// Turn into zombie
        
zp_core_infect(victimattacker)
        
        
// Victim's sound
        
ArrayGetString(g_sound_grenade_infect_playerrandom_num(0ArraySize(g_sound_grenade_infect_player) - 1), soundcharsmax(sound))
        
emit_sound(victimCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
    }
    
    
// Get rid of the grenade
    
engfunc(EngFunc_RemoveEntityent)

Nope cant compile.
__________________
H.RED.ZONE is offline
Snaker beatter
Veteran Member
Join Date: Sep 2011
Location: Manila, Philippines
Old 02-07-2012 , 11:42   Re: Code error
Reply With Quote #4

No like this:

PHP Code:
// Infection Bomb Explosion
infection_explode(ent)
{
    if (!
pev_valid(ent)
    {
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
// Round ended
    
if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Get origin
    
static Float:origin[3]
    
pev(entpev_originorigin)
    
    
// Make the explosion
    
create_blast(origin)
    
    
// Infection nade explode sound
    
static sound[SOUND_MAX_LENGTH]
    
ArrayGetString(g_sound_grenade_infect_exploderandom_num(0ArraySize(g_sound_grenade_infect_explode) - 1), soundcharsmax(sound))
    
emit_sound(entCHAN_WEAPONsound1.0ATTN_NORM0PITCH_NORM)
    
    
// Get attacker
    
new attacker pev(entpev_owner)
    
    
// Infection bomb owner disconnected or not zombie anymore?
    
if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Collisions
    
new victim = -1
    
    
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginNADE_EXPLOSION_RADIUS)) != 0)
    {
        
// Only effect alive humans
        
if (!is_user_alive(victim) || zp_core_is_zombie(victim))
            continue;
        
        
// Last human is killed
        
if (zp_core_get_human_count() == 1)
        {
            
ExecuteHamB(Ham_Killedvictimattacker0)
            continue;
        }
        
        
// Turn into zombie
        
zp_core_infect(victimattacker)
        
        
// Victim's sound
        
ArrayGetString(g_sound_grenade_infect_playerrandom_num(0ArraySize(g_sound_grenade_infect_player) - 1), soundcharsmax(sound))
        
emit_sound(victimCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
    }
    
    
// Get rid of the grenade
    
engfunc(EngFunc_RemoveEntityent)

EDIT:

Sorry is likes this
PHP Code:
// Infection Bomb Explosion
infection_explode(ent)
{
    if (!
pev(entpev_valid))
    {
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
// Round ended
    
if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Get origin
    
static Float:origin[3]
    
pev(entpev_originorigin)
    
    
// Make the explosion
    
create_blast(origin)
    
    
// Infection nade explode sound
    
static sound[SOUND_MAX_LENGTH]
    
ArrayGetString(g_sound_grenade_infect_exploderandom_num(0ArraySize(g_sound_grenade_infect_explode) - 1), soundcharsmax(sound))
    
emit_sound(entCHAN_WEAPONsound1.0ATTN_NORM0PITCH_NORM)
    
    
// Get attacker
    
new attacker pev(entpev_owner)
    
    
// Infection bomb owner disconnected or not zombie anymore?
    
if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Collisions
    
new victim = -1
    
    
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginNADE_EXPLOSION_RADIUS)) != 0)
    {
        
// Only effect alive humans
        
if (!is_user_alive(victim) || zp_core_is_zombie(victim))
            continue;
        
        
// Last human is killed
        
if (zp_core_get_human_count() == 1)
        {
            
ExecuteHamB(Ham_Killedvictimattacker0)
            continue;
        }
        
        
// Turn into zombie
        
zp_core_infect(victimattacker)
        
        
// Victim's sound
        
ArrayGetString(g_sound_grenade_infect_playerrandom_num(0ArraySize(g_sound_grenade_infect_player) - 1), soundcharsmax(sound))
        
emit_sound(victimCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
    }
    
    
// Get rid of the grenade
    
engfunc(EngFunc_RemoveEntityent)

__________________

Last edited by Snaker beatter; 02-07-2012 at 11:48.
Snaker beatter is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 02-07-2012 , 12:50   Re: Code error
Reply With Quote #5

I stil get compile error.
syntax error in expression
__________________
H.RED.ZONE is offline
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 02-07-2012 , 20:11   Re: Code error
Reply With Quote #6

Looks like the problem is in "create_blast" function.

PHP Code:
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
write_byte(TE_EXPLOSION); // TE_EXPLOSION
    
write_coord(floatround(origin[0])); // origin x
    
write_coord(floatround(origin[1])); // origin y
    
write_coord(floatround(origin[2] + 50.0)); // origin z
    
write_short(g_InfectionSpr); // sprites
    
write_byte(25); // scale in 0.1's
    
write_byte(10); // framerate
    
write_byte(14); // flags 
    
message_end(); // message end 
Comment that part and tell us if it works.
XINLEI is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 02-07-2012 , 20:21   Re: Code error
Reply With Quote #7

Quote:
Originally Posted by XINLEI View Post
Looks like the problem is in "create_blast" function.

PHP Code:
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
write_byte(TE_EXPLOSION); // TE_EXPLOSION
    
write_coord(floatround(origin[0])); // origin x
    
write_coord(floatround(origin[1])); // origin y
    
write_coord(floatround(origin[2] + 50.0)); // origin z
    
write_short(g_InfectionSpr); // sprites
    
write_byte(25); // scale in 0.1's
    
write_byte(10); // framerate
    
write_byte(14); // flags 
    
message_end(); // message end 
Comment that part and tell us if it works.
Nope that is my effect i think the problem is in other plugin causing that error i had lot of tests with other plugins (they all work together) and i get that error a lot now the thing is i had that same error before i added TE_EXPLOSION And thats not a problem. (:
__________________
H.RED.ZONE is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 02-08-2012 , 11:37   Re: Code error
Reply With Quote #8

lol no need to remove an invalid entity, it may cause server crash.
As for your error its really weird....Does is happen often ?
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 02-08-2012 , 12:27   Re: Code error
Reply With Quote #9

Hmm 3 - 4 hours.

EDIT: Nope my bad
Code:
L 02/08/2012 - 15:03:15: [ZP] Invalid Player (22)
L 02/08/2012 - 15:03:15: [AMXX] Displaying debug trace (plugin "zp50_item_infection_bomb.amxx")
L 02/08/2012 - 15:03:15: [AMXX] Run time error 10: native error (native "zp_core_infect")
L 02/08/2012 - 15:03:15: [AMXX]    [0] zp50_item_infection_bomb.sma::infection_explode (line 317)
L 02/08/2012 - 15:03:15: [AMXX]    [1] zp50_item_infection_bomb.sma::fw_ThinkGrenade (line 258)
L 02/08/2012 - 15:40:33: Start of error session.
L 02/08/2012 - 15:40:33: Info (map "zm_fun_world_2") (file "addons/amxmodx/logs/error_20120208.log")
L 02/08/2012 - 15:40:33: [ZP] Invalid Player (24)
L 02/08/2012 - 15:40:33: [AMXX] Displaying debug trace (plugin "zp50_item_infection_bomb.amxx")
L 02/08/2012 - 15:40:33: [AMXX] Run time error 10: native error (native "zp_core_infect")
L 02/08/2012 - 15:40:33: [AMXX]    [0] zp50_item_infection_bomb.sma::infection_explode (line 317)
L 02/08/2012 - 15:40:33: [AMXX]    [1] zp50_item_infection_bomb.sma::fw_ThinkGrenade (line 258)
Look at the time :S
__________________

Last edited by H.RED.ZONE; 02-08-2012 at 13:01.
H.RED.ZONE is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 02-09-2012 , 02:54   Re: Code error
Reply With Quote #10

Code:
L 02/08/2012 - 15:40:33: [ZP] Invalid Player (22)
Code:
L 02/08/2012 - 15:40:33: [ZP] Invalid Player (24)
I believe you need to make a check if the killer/victim alive.
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh 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:37.


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