Raised This Month: $535 Target: $400
 133% 

weird errors - invalid return values


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 05-16-2017 , 01:13   weird errors - invalid return values
Reply With Quote #1

[FIXED] Although facing moving sprite problems.

I'm getting weird errors when retrieving pev values of custom entities. For example I tried to store entity index in pev_iuser2 and it returns some invalid data. I have no clue whats wrong and been debuging for whole day and two nights. I've stopped on retrieving pev_classname in fm_find_ent_in_sphere and printing it - it gives:
Quote:
L 05/16/2017 - 05:49:54: String formatted incorrectly - parameter 11 (total 10)
L 05/16/2017 - 05:49:54: [AMXX] Displaying debug trace (plugin "voi_smoke_room.amxx", version "0.1")
L 05/16/2017 - 05:49:54: [AMXX] Run time error 25: parameter error
L 05/16/2017 - 05:49:54: [AMXX] [0] voi_smoke_room.sma::fire (line 53)
PHP Code:
/* Script generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <xs>
#define PLUGIN    "Smoke Room"
#define AUTHOR    "Voi"
#define VERSION    "0.1"
//new const room_smoke_spr[] =  "sprites/voi/smoke_room17.spr"  
public plugin_init()
{
    
register_forward(FM_Think,"smoke_think",0)
    
//    register_think("sprajt", "sprite_think")
    
register_clcmd("say /test","fire")
    
register_plugin(PLUGINVERSIONAUTHOR)
    
// Add your own code here
}
public 
plugin_precache()
{
    
//precache_model(room_smoke_spr)
}
public 
fire(id)
{
    new 
Float:gunpos[3], stringClassname[24]
    
//ExecuteHam(Ham_Player_GetGunPosition, id, gunpos)
    
    
new Float:origin[3]
    
pev(idpev_originorigin)
    new 
foundeIndex[2]
    new 
entity = -1
    client_print
(idprint_chat"DEBUG: fire!(CHECKING FOR SMOKE)")
    while( (
entity fm_find_ent_in_sphere(entityorigin128.0)) > 0)
    {
        if(!
fm_is_valid_ent(entity))    
            continue
        
pev(entitypev_classnamestringClassnamecharsmax(stringClassname))
        
client_print(idprint_chat"DEBUG: CLASSNAME = %s"stringClassname)
        
//
        //if( equali("info_target", stringClassname) && pev(entity, pev_iuser4) == 666 )
        
if(pev(entitypev_iuser4) == 666 )
        {
            
/*new check
            pev(entity, pev_iuser4, check)
            if(check != 666)
                continue*/
            
found += 1
            
if(found == 1)
                
eIndex[0] = entity
            
else if(found == 2)
                
eIndex[1] = entity
            client_print
(idprint_chat"DEBUG: SMOKE FOUND! %i %s, eIndex[0] = %i, eIndex[1] = %i iuser4 =%i iuser2=%i found=%i classname = %s"entitystringClassnameeIndex[0],eIndex[1],pev(entitypev_iuser4), pev(entitypev_iuser2), found )
        }    
        
    }  
    if(!
found)
    {
        
client_print(idprint_chat"DEBUG: SMOKE NOT FOUND - CREATING NEW SMOKE!, found = %i",found)
        
create_room_smoke(id)
    }
    else
    {
        new 
Float:Eorigin1[3], Float:Eorigin2[3]
        if(
eIndex[0])
            
pev(eIndex[0], pev_originEorigin1)
        if(
eIndex[1])
            
pev(eIndex[1], pev_originEorigin2)
        if(
get_distance_f(originEorigin1) > get_distance_f(originEorigin2) && eIndex[1])
            
smoke_increase(ideIndex[1])
        else if(
eIndex[0])
            
smoke_increase(ideIndex[0])
    }
}
public 
create_room_smoke(id)
{
    new 
iEntO fm_create_entity("info_target")
    if(!
pev_valid(iEntO))
    {
        return
    }
    new 
Float:origin[3]
    
pev(idpev_originorigin)
    
set_pev(iEntOpev_classname"info_target")
    
set_pev(iEntOpev_originorigin)
    
set_pev(iEntOpev_movetypeMOVETYPE_FLY)
    
set_pev(iEntOpev_solidSOLID_TRIGGER)
    
set_pev(iEntOpev_iuser4666 )
    
set_pev(iEntOpev_nextthinkget_gametime()+0.1)
    
//engfunc(EngFunc_SetSize, iEntO, Float:{64.0, 64.0, 64.0} , Float:{64.0, 64.0, 64.0})
    /*new iEnt = fm_create_entity("info_target")
    
    if(!pev_valid(iEnt))
    {
    server_print("DEBUG: qENTITY = %i", iEnt)
    return
    }
    //
    set_pev(iEntO, pev_iuser2, iEnt)
    new qrwa
    
    server_cmd("say DEBUG: iEnt = %i, valid = %i",     pev(iEntO, pev_iuser2), pev_valid(    pev(iEntO, pev_iuser2)))
    //set an origin by yourself
    engfunc(EngFunc_SetModel, iEnt, room_smoke_spr)
    //engfunc(EngFunc_SetSize, iEnt, Float:{0.0, 0.0, 0.0} , Float:{0.0, 0.0, 0.0})
    set_pev(iEnt, pev_classname, "info_target")
    
    set_pev(iEnt, pev_origin, origin)
    //set_pev(iEnt, pev_aiment, iEntO)
    set_pev(iEnt, pev_scale, 0.3)
    //set_pev(iEnt, pev_movetype, MOVETYPE_FOLLOW)
    set_pev(iEnt, pev_solid, SOLID_NOT)
    set_pev(iEnt, pev_rendermode, kRenderTransAlpha)
    set_pev(iEnt, pev_renderamt, 100.0)
    set_pev(iEnt, pev_iuser4, 667 )
    set_pev(iEnt, pev_nextthink, halflife_time()+0.01)
    //dllfunc(DLLFunc_Spawn, iEnt)    */
    
}
public 
smoke_increase(idiEntO)
{
    new 
Float:scaleFloat:renderamtFloat:entityvelocity[3], Float:playervelocity[3], Float:gunvelocity[3]
    
    
pev(idpev_velocityplayervelocity)
    
pev(iEntOpev_velocityentityvelocity)
    
velocity_by_aim(id1000gunvelocity)
    
xs_vec_add(gunvelocityplayervelocityplayervelocity)
    
xs_vec_mul_scalar(playervelocity0.1playervelocity)
    
xs_vec_add(entityvelocityplayervelocityentityvelocity)
    
    
set_pev(iEntOpev_velocityentityvelocity)
    
client_print(idprint_chat"DEBUG: SMOKE VELOCITY ADDED = %f %f %f"entityvelocity[0], entityvelocity[1], entityvelocity[2])

    new 
iEnt pev(iEntOpev_iuser2)
        if(!
fm_is_valid_ent(iEnt))
        return 
FMRES_IGNORED
    client_print
(idprint_chat"DEBUG: SMOKE INCREASE, SPRITE ENTITY = %i"iEnt)
    
    
pev(iEntpev_scalescale)
    
pev(iEntpev_renderamtrenderamt)
    
    
    
scale += 0.025
    renderamt 
+= 5.0
    set_pev
(iEntpev_scalescale)
    
set_pev(iEntpev_renderamtrenderamt)
    
    
//set_pev(id, pev_velocity, entityvelocity)
    
    
return FMRES_IGNORED
}


public 
smoke_think(iEntO)
{
    if(!
fm_is_valid_ent(iEntO)|| pev(iEntOpev_iuser4) != 666)
        return 
FMRES_IGNORED
    
new Float:origin[3]
    
pev(iEntOpev_originorigin)
    
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
    
write_byte(TE_GUNSHOT)
    
write_coord(floatround(origin[0]))    // start position
    
write_coord(floatround(origin[1]))
    
write_coord(floatround(origin[2]))
    
message_end()
    
/*new check
    pev(iEntO, pev_iuser4, check)
    if(check != 666)
        return FMRES_IGNORED*/
    
new Float:renderamtFloat:scaleiEnt
    
    set_pev
(iEntOpev_nextthinkget_gametime()+0.1)
    if(!
fm_is_valid_ent(iEnt))
        return 
FMRES_IGNORED
    pev
(iEntpev_scalescale)
    
pev(iEntpev_renderamtrenderamt)
    
scale *= 1.01
    renderamt 
+= 1.0
    
/*if(renderamt < 2.0)
    {
    remove_entity(iEntO)
    remove_entity(iEnt)
    return FMRES_IGNORED
    }*/
    
    
set_pev(iEntpev_scalescale)
    
set_pev(iEntpev_renderamtrenderamt)
    
    
    return 
FMRES_IGNORED
}
public 
sprite_think(iEnt)
{
    if(!
fm_is_valid_ent(iEnt))
        return 
FMRES_IGNORED
    set_pev
(iEntpev_nextthinkget_gametime()+0.1)
    return 
FMRES_IGNORED

Any coding tips are welcome . Code is bit messy cause I'm debuging the plugin and errors don't have any sense . Looks like the problem is elsewhere. I have newest hlds from sourcecmd, Metamod v1.21.1-am and AMX Mod X 1.8.3-dev+5116.

This plugin is in development and when I overcome some issues(like server side dynamic sprites) it will provide hugely dynamic weapon smoke system with dynamic wind patterns etc.

Last edited by VoivoDpl; 05-16-2017 at 16:16.
VoivoDpl is offline
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 05-16-2017 , 02:05   Re: weird errors - invalid return values
Reply With Quote #2

Your last %s is not linked to any variable.

i.e.: ( Line 53 ... pev(entity, pev_iuser2), found, classname_string )
vitorrossi is offline
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 05-16-2017 , 02:29   Re: weird errors - invalid return values
Reply With Quote #3

Thanks! One thing fixed. Need to look back at storing entity index in pev_iuser2, it was returning values such as 11238712 instead of like 142.
VoivoDpl is offline
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 05-16-2017 , 03:16   Re: weird errors - invalid return values
Reply With Quote #4

Quote:
DEBUG: SMOKE THINK ENTITY = 127, SMOKE ID = 666, SPRITE ID =1124073472
I store secondary entity id in pev_iuser2, but when I later retrieve it in "think" function it gives wrong returns:
Quote:
SPRITE ID =1124073472
What am I doing wrong here ? I did this like 5 years ago and it worked (I think). Posting new code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <xs>
#define PLUGIN    "Smoke Room"
#define AUTHOR    "Voi"
#define VERSION    "0.1"
#define SMOKE_THINKER 666
#define SMOKE_SPRITE 667
//new const room_smoke_spr[] =  "sprites/voi/smoke_room17.spr"  
public plugin_init()
{
    
register_forward(FM_Think,"smoke_think",0)
    
//    register_think("sprajt", "sprite_think")
    
register_clcmd("say /test","fire")
    
register_plugin(PLUGINVERSIONAUTHOR)
    
// Add your own code here
}
public 
plugin_precache()
{
    
precache_model(room_smoke_spr)
}
public 
fire(id)
{
    new 
Float:gunpos[3], stringClassname[24]
    
//ExecuteHam(Ham_Player_GetGunPosition, id, gunpos)
    
    
new Float:origin[3]
    
pev(idpev_originorigin)
    new 
foundeIndex[2]
    new 
entity = -1
    client_print
(idprint_chat"DEBUG: fire!(CHECKING FOR SMOKE)")
    while( (
entity fm_find_ent_in_sphere(entityorigin128.0)) > 0)
    {
        if(!
fm_is_valid_ent(entity))    
            continue
        
//pev(entity, pev_classname, stringClassname, charsmax(stringClassname))
        //client_print(id, print_chat, "DEBUG: CLASSNAME = %s", stringClassname)
        //
        //if( equali("info_target", stringClassname) && pev(entity, pev_iuser4) == 666 )
        
if(pev(entitypev_iuser4) == SMOKE_THINKER )
        {
            
/*new check
            pev(entity, pev_iuser4, check)
            if(check != 666)
                continue*/
            
found += 1
            
if(found == 1)
                
eIndex[0] = entity
            
else if(found == 2)
                
eIndex[1] = entity
            client_print
(idprint_chat"DEBUG: SMOKE FOUND! %i %s, eIndex[0] = %i, eIndex[1] = %i iuser4 =%i iuser2=%i found=%i"entitystringClassnameeIndex[0],eIndex[1],pev(entitypev_iuser4), pev(entitypev_iuser2), found )
        }    
        
    }  
    if(!
found)
    {
        
client_print(idprint_chat"DEBUG: SMOKE NOT FOUND - CREATING NEW SMOKE!, found = %i",found)
        
create_room_smoke(id)
    }
    else
    {
        new 
Float:Eorigin1[3], Float:Eorigin2[3]
        if(
eIndex[0])
            
pev(eIndex[0], pev_originEorigin1)
        if(
eIndex[1])
            
pev(eIndex[1], pev_originEorigin2)
        if(
get_distance_f(originEorigin1) > get_distance_f(originEorigin2) && eIndex[1])
            
smoke_increase(ideIndex[1])
        else if(
eIndex[0])
            
smoke_increase(ideIndex[0])
    }
}
public 
create_room_smoke(id)
{
    new 
iEntO fm_create_entity("info_target")
    if(!
pev_valid(iEntO))
    {
        return
    }
    new 
Float:origin[3]
    
pev(idpev_originorigin)
    
set_pev(iEntOpev_classname"info_target")
    
set_pev(iEntOpev_originorigin)
    
set_pev(iEntOpev_movetypeMOVETYPE_BOUNCEMISSILE)
    
set_pev(iEntOpev_solidSOLID_TRIGGER)
    
set_pev(iEntOpev_iuser4SMOKE_THINKER )
    
set_pev(iEntOpev_nextthinkget_gametime()+0.1)
    
//engfunc(EngFunc_SetSize, iEntO, Float:{64.0, 64.0, 64.0} , Float:{64.0, 64.0, 64.0})
    
new iEnt fm_create_entity("info_target")
    
    if(!
pev_valid(iEnt))
    {
        
server_print("DEBUG: qENTITY = %i"iEnt)
        return
    }
    
//
    
set_pev(iEntOpev_iuser2iEnt)
    
    
    
server_cmd("say DEBUG: iEnt = %i, valid = %i",     pev(iEntOpev_iuser2), pev_valid(    pev(iEntOpev_iuser2)))
    
//set an origin by yourself
    
engfunc(EngFunc_SetModeliEntroom_smoke_spr)
    
//engfunc(EngFunc_SetSize, iEnt, Float:{0.0, 0.0, 0.0} , Float:{0.0, 0.0, 0.0})
    
set_pev(iEntpev_classname"info_target")
    
    
set_pev(iEntpev_originorigin)
    
set_pev(iEntpev_aimentiEntO)
    
set_pev(iEntpev_scale0.3)
    
set_pev(iEntpev_movetypeMOVETYPE_FOLLOW)
    
set_pev(iEntpev_solidSOLID_NOT)
    
set_pev(iEntpev_rendermodekRenderTransAlpha)
    
set_pev(iEntpev_renderamt100.0)
    
set_pev(iEntpev_iuser4SMOKE_SPRITE )
    
set_pev(iEntpev_nextthinkget_gametime()+0.01)
    
//dllfunc(DLLFunc_Spawn, iEnt)    */
    
}
public 
smoke_increase(idiEntO)
{
    new 
Float:scaleFloat:renderamtFloat:entityvelocity[3], Float:playervelocity[3], Float:gunvelocity[3]
    
    
pev(idpev_velocityplayervelocity)
    
pev(iEntOpev_velocityentityvelocity)
    
velocity_by_aim(id1000gunvelocity)
    
xs_vec_add(gunvelocityplayervelocityplayervelocity)
    
xs_vec_mul_scalar(playervelocity0.01playervelocity)
    
xs_vec_add(entityvelocityplayervelocityentityvelocity)
    
    
set_pev(iEntOpev_velocityentityvelocity)
    
client_print(idprint_chat"DEBUG: SMOKE VELOCITY ADDED = %f %f %f"entityvelocity[0], entityvelocity[1], entityvelocity[2])
    
    new 
iEnt pev(iEntOpev_iuser2)
    if(!
fm_is_valid_ent(iEnt))
        return 
FMRES_IGNORED
    client_print
(idprint_chat"DEBUG: SMOKE INCREASE, SPRITE ENTITY = %i"iEnt)
    
    
pev(iEntpev_scalescale)
    
pev(iEntpev_renderamtrenderamt)
    
    
    
scale += 0.025
    renderamt 
+= 5.0
    set_pev
(iEntpev_scalescale)
    
set_pev(iEntpev_renderamtrenderamt)
    
    
//set_pev(id, pev_velocity, entityvelocity)
    
    
return FMRES_IGNORED
}


public 
smoke_think(iEntO)
{
    if(!
fm_is_valid_ent(iEntO) )
        return 
FMRES_IGNORED
    
new smoke_id pev(iEntOpev_iuser4)
    new 
iEnt 
    pev
(iEntOpev_iuser2iEnt)
    
server_print("DEBUG: SMOKE THINK ENTITY = %i, SMOKE ID = %i, SPRITE ID =%i"iEntOsmoke_idiEnt)
    if ( 
smoke_id == SMOKE_THINKER)
    {
        
debug_gunshot(iEntO)
        
set_pev(iEntOpev_nextthinkget_gametime()+0.1)
        
    }
    else if(
smoke_id == SMOKE_SPRITE)
    {
        
        
        new 
Float:renderamtFloat:scale
        pev
(iEntpev_scalescale)
        
pev(iEntpev_renderamtrenderamt)
        
scale *= 1.01
        renderamt 
+= 1.0
        set_pev
(iEntpev_scalescale)
        
set_pev(iEntpev_renderamtrenderamt)
        
set_pev(iEntpev_nextthinkget_gametime()+0.01)
    }
    return 
FMRES_IGNORED
}
public 
sprite_think(iEnt)
{
    if(!
fm_is_valid_ent(iEnt))
        return 
FMRES_IGNORED
    
    
return FMRES_IGNORED
}
public 
debug_gunshot(iEnt)
{
    new 
Float:origin[3]
    
pev(iEntpev_originorigin)
    
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
    
write_byte(TE_GUNSHOT)
    
write_coord(floatround(origin[0]))    // start position
    
write_coord(floatround(origin[1]))
    
write_coord(floatround(origin[2]))
    
message_end()


Last edited by VoivoDpl; 05-16-2017 at 03:19.
VoivoDpl is offline
[email protected]
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-16-2017 , 03:23   Re: weird errors - invalid return values
Reply With Quote #5

Code:
    new iEnt     pev(iEntO, pev_iuser2, iEnt)
->
Code:
    new iEnt = pev(iEntO, pev_iuser2)
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 05-16-2017 , 03:26   Re: weird errors - invalid return values
Reply With Quote #6

Ok thanks, but why is that?
VoivoDpl is offline
[email protected]
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-16-2017 , 03:50   Re: weird errors - invalid return values
Reply With Quote #7

https://github.com/alliedmodders/amx...ta.inc#L29-L30
https://github.com/alliedmodders/amx....inc#L737-L738
__________________

Last edited by [email protected]; 05-16-2017 at 03:55.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 05-16-2017 , 05:05   Re: weird errors - invalid return values
Reply With Quote #8

Thanks.
How do I make the sprite entity to move and be dynamic, not client spawned(not temp entity and not dllfunc_spawn) ? When I set the movetype the entity doesn't draw sprite. The (quake) gun ricochet is for debuging to indicate entity think :-).

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <xs>
#define PLUGIN    "Smoke Room"
#define AUTHOR    "Voi"
#define VERSION    "0.1"
#define SMOKE_THINKER 666
#define SMOKE_SPRITE 667
new const room_smoke_spr[] =  "sprites/voi/smoke_room17.spr"  
public plugin_init()
{
    
register_forward(FM_Think,"smoke_think",0)
    
//register_think("env_sprite", "sprite_think")
    
register_clcmd("say /test","fire")
    
register_plugin(PLUGINVERSIONAUTHOR)
    
// Add your own code here
}
public 
plugin_precache()
{
    
precache_model(room_smoke_spr)
}
public 
fire(id)
{
    new 
Float:gunpos[3], stringClassname[24]
    
//ExecuteHam(Ham_Player_GetGunPosition, id, gunpos)
    
    
new Float:origin[3]
    
pev(idpev_originorigin)
    new 
foundeIndex[2]
    new 
entity = -1
    client_print
(idprint_chat"DEBUG: fire!(CHECKING FOR SMOKE)")
    while( (
entity fm_find_ent_in_sphere(entityorigin128.0)) > 0)
    {
        if(!
fm_is_valid_ent(entity))    
            continue
        
//pev(entity, pev_classname, stringClassname, charsmax(stringClassname))
        //client_print(id, print_chat, "DEBUG: CLASSNAME = %s", stringClassname)
        //
        //if( equali("info_target", stringClassname) && pev(entity, pev_iuser4) == 666 )
        
if(pev(entitypev_iuser4) == SMOKE_THINKER )
        {
            
/*new check
            pev(entity, pev_iuser4, check)
            if(check != 666)
                continue*/
            
found += 1
            
if(found == 1)
                
eIndex[0] = entity
            
else if(found == 2)
                
eIndex[1] = entity
            client_print
(idprint_chat"DEBUG: SMOKE FOUND! %i %s, eIndex[0] = %i, eIndex[1] = %i iuser4 =%i iuser2=%i found=%i"entitystringClassnameeIndex[0],eIndex[1],pev(entitypev_iuser4), pev(entitypev_iuser2), found )
        }    
        
    }  
    if(!
found)
    {
        
client_print(idprint_chat"DEBUG: SMOKE NOT FOUND - CREATING NEW SMOKE!, found = %i",found)
        
create_room_smoke(id)
    }
    else
    {
        new 
Float:Eorigin1[3], Float:Eorigin2[3]
        if(
eIndex[0])
            
pev(eIndex[0], pev_originEorigin1)
        if(
eIndex[1])
            
pev(eIndex[1], pev_originEorigin2)
        if(
get_distance_f(originEorigin1) > get_distance_f(originEorigin2) && eIndex[1])
            
smoke_increase(ideIndex[1])
        else if(
eIndex[0])
            
smoke_increase(ideIndex[0])
    }
}
public 
create_room_smoke(id)
{
    new 
iEntO fm_create_entity("info_target")
    if(!
pev_valid(iEntO))
    {
        return
    }
    new 
Float:origin[3]
    
pev(idpev_originorigin)
    
set_pev(iEntOpev_classname"info_target")
    
set_pev(iEntOpev_originorigin)
    
set_pev(iEntOpev_movetypeMOVETYPE_BOUNCEMISSILE)
    
set_pev(iEntOpev_solidSOLID_TRIGGER)
    
set_pev(iEntOpev_iuser4SMOKE_THINKER )
    
set_pev(iEntOpev_nextthinkget_gametime()+0.1)
    
//engfunc(EngFunc_SetSize, iEntO, Float:{64.0, 64.0, 64.0} , Float:{64.0, 64.0, 64.0})
    
new iEnt fm_create_entity("env_sprite")
    
    if(!
pev_valid(iEnt))
    {
        
server_print("DEBUG: qENTITY = %i"iEnt)
        return
    }
    
//
    
set_pev(iEntOpev_iuser2iEnt)
        
    
    
server_cmd("say DEBUG: iEnt = %i, valid = %i",     pev(iEntOpev_iuser2), pev_valid(    pev(iEntOpev_iuser2)))
    
    
engfunc(EngFunc_SetModeliEntroom_smoke_spr)
    
engfunc(EngFunc_SetSizeiEntFloat:{0.00.00.0} , Float:{0.00.00.0})
    
set_pev(iEntpev_classname"sprajt")
    
set_pev(iEntpev_spawnflagsSF_SPRITE_STARTON)
    
set_pev(iEntpev_originorigin)

    
set_pev(iEntpev_scale0.3)
    
set_pev(iEntpev_aimentiEntO)
    
set_pev(iEntpev_solidSOLID_NOT)
    
set_pev(iEntpev_rendermodekRenderTransAlpha)
    
set_pev(iEntpev_renderamt100.0)
    
set_pev(iEntpev_iuser4SMOKE_SPRITE )
    
set_pev(iEntpev_velocity, {0.00.050.0})
    
set_pev(iEntpev_nextthinkget_gametime()+0.01)
    
set_pev(iEntpev_movetypeMOVETYPE_FOLLOW )


}
public 
smoke_increase(idiEntO)
{
    new 
Float:scaleFloat:renderamtFloat:entityvelocity[3], Float:playervelocity[3], Float:gunvelocity[3]
    
    
pev(idpev_velocityplayervelocity)
    
pev(iEntOpev_velocityentityvelocity)
    
velocity_by_aim(id1000gunvelocity)
    
xs_vec_add(gunvelocityplayervelocityplayervelocity)
    
xs_vec_mul_scalar(playervelocity0.01playervelocity)
    
xs_vec_add(entityvelocityplayervelocityentityvelocity)
    
    
set_pev(iEntOpev_velocityentityvelocity)
    
client_print(idprint_chat"DEBUG: SMOKE VELOCITY ADDED = %f %f %f"entityvelocity[0], entityvelocity[1], entityvelocity[2])
    
    new 
iEnt pev(iEntOpev_iuser2)
    if(!
fm_is_valid_ent(iEnt))
        return 
FMRES_IGNORED
    client_print
(idprint_chat"DEBUG: SMOKE INCREASE, SPRITE ENTITY = %i"iEnt)
    
    
pev(iEntpev_scalescale)
    
pev(iEntpev_renderamtrenderamt)
    
    
    
scale += 0.025
    renderamt 
+= 5.0
    set_pev
(iEntpev_scalescale)
    
set_pev(iEntpev_renderamtrenderamt)
    
    
//set_pev(id, pev_velocity, entityvelocity)
    
    
return FMRES_IGNORED
}


public 
smoke_think(iEntO)
{
    if(!
fm_is_valid_ent(iEntO) )
        return 
FMRES_IGNORED
    
new smoke_id pev(iEntOpev_iuser4)
    new 
iEnt pev(iEntOpev_iuser2)
    if(
smoke_id)
    
server_print("DEBUG: SMOKE THINK ENTITY = %i, SMOKE ID = %i, SPRITE ID =%i"iEntOsmoke_idiEnt)
    if ( 
smoke_id == SMOKE_THINKER)
    {
        
        
set_pev(iEntOpev_nextthinkget_gametime()+0.1)
        
smoke_id pev(iEntpev_iuser4)
    }
    if(
smoke_id == SMOKE_SPRITE)
    {
        new 
Float:renderamtFloat:scale
        pev
(iEntpev_scalescale)
        
pev(iEntpev_renderamtrenderamt)
        
scale *= 1.001
        renderamt 
+= 1.0
        set_pev
(iEntpev_scalescale)
        
set_pev(iEntpev_renderamtrenderamt)
        
set_pev(iEntpev_nextthinkget_gametime()+0.1)
        
debug_gunshot(iEnt)

    }
    return 
FMRES_IGNORED
}
public 
sprite_think(iEnt)
{
    if(!
fm_is_valid_ent(iEnt))
        return 
FMRES_IGNORED
    
    
new smoke_id pev(iEntpev_iuser4)
    if(
smoke_id != SMOKE_SPRITE)
                return 
FMRES_IGNORED

    
return FMRES_IGNORED
}
public 
debug_gunshot(iEnt)
{
    new 
Float:origin[3]
    
pev(iEntpev_originorigin)
    
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
    
write_byte(TE_GUNSHOT)
    
write_coord(floatround(origin[0]))    // start position
    
write_coord(floatround(origin[1]))
    
write_coord(floatround(origin[2]))
    
message_end()

Attached Files
File Type: zip smoke_room17.zip (19.6 KB, 29 views)
VoivoDpl is offline
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 05-16-2017 , 11:45   Re: weird errors - invalid return values
Reply With Quote #9

Look at this in case you're still having issues with pev_iuser
https://forums.alliedmods.net/showthread.php?t=294188
vitorrossi is offline
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 05-16-2017 , 13:40   Re: weird errors - invalid return values
Reply With Quote #10

Thanks. All "works" now except sprite velocity(movetype)+pev_model(drawing of sprite) at the same time. I don't really need to store that much of custom data, but good to know.

I have read how to do this on other threads and I think I'm doing it the same. What am I doing wrong ?
VoivoDpl is offline
Reply


Thread Tools
Display Modes

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 20:45.


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