AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help generating smoke (https://forums.alliedmods.net/showthread.php?t=47370)

hip_hop_x 11-16-2006 12:49

Need help generating smoke
 
I need some help. I want to generate some smoke from all alive players

I made:
PHP Code:

public plugin_init() {
    
register_plugin("ShNS""1.0""Hip_hop_x")
    
    
register_logevent("new_round"2"1=Round_Start")
}
public 
new_round(id) {
new 
smoke
smoke 
precache_model("sprites/steam1.spr")

    if(
is_user_alive(id)) {
        if(
get_cvar_num("sv_nadetail"))
                    {
                    new 
origin[3]
                    new 
mata
                    mata 
=  get_user_origin(idorigin2)
                        
message_begin(MSG_ALL ,SVC_TEMPENTITY)
                        
write_byteTE_SMOKE )
                        
write_coord(mata)    
                        
write_coord(mata)
                        
write_coord(mata)
                        
write_short(smoke)
                        
write_byte50 )    // scale in 0.1's
                        
write_byte10 )   // framerate
                        
message_end()
                    } 
    
                } 
    else     {    
    return 
PLUGIN_CONTINUE    
        
} return PLUGIN_HANDLED


How should I set the smoke to all alive players? And how to fix the warnings? Can you help me?

VEN 11-16-2006 14:32

Re: Need help generating smoke
 
precache_model should be in plugin_precache
id isn't passed to the logevent hook, so you should use for example get_players with "a" flag and loop through all indexes, you can find examples in amxmodx/scripting in some of the sma files
It would be better to use MSG_PVS instead of MSG_ALL for visual effects like this one, and pass the origin of the message in message_begin
should be write_coord(origin[0]), write_coord(origin[1]) and write_coord(origin[2])

hip_hop_x 11-16-2006 15:38

Re: Need help generating smoke
 
Thanks VEN, I'll try it tommorow.

dutchmeat 11-17-2006 04:54

Re: Need help generating smoke
 
So it should be:

Code:

#include <amxmodx>
public plugin_init() {
    register_plugin("ShNS", "1.0", "Hip_hop_x")
 
    register_logevent("new_round", 2, "1=Round_Start")
}
new smoke //outside new_round
public new_round(id) {
for(new a = 1; a <= get_playersnum(); a++) {
        if(get_cvar_num("sv_nadetail"))
        {
                    new origin[3]
                    get_user_origin(id,origin)
                    message_begin(MSG_PVS,SVC_TEMPENTITY)
                    write_byte( 5 ) //TE_SMOKE
                    write_coord(origin[0])   
                    write_coord(origin[1])
                    write_coord(origin[2])
                    write_short(smoke)
                    write_byte( 50 )    // scale in 0.1's
                    write_byte( 10 )  // framerate
                    message_end()
        }else{   
      return PLUGIN_CONTINUE   
        }
}
return PLUGIN_HANDLED
}
 
public plugin_precache(){ //precache the models/sprites/sounds/ whatever
smoke = precache_model("sprites/steam1.spr")
}

If you want a trail that follows the player, you can use this:

Code:

#include <amxmodx>
public plugin_init() {
    register_plugin("PlayerTrail", "1.0", "Dutchmeat")
}
new smoke
public server_frame() {
for(new a = 1; a <= get_playersnum(); a++) {
if(is_user_alive(a)){  //make sure the client is connected and alive
message_begin( MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22) //#define TE_BEAMFOLLOW 22 Create a line of decaying beam segments until entity stops moving
write_short(a)  //player
write_short(smoke) //Sprite
write_byte(6)  //Life 
write_byte(5)  // Width
write_byte(255)  // red
write_byte(255)  // green
write_byte(255)  // blue
write_byte(80)  // Brightness
message_end()
}
}
}
public plugin_precache(){ //precache the models/sprites/sounds/ whatever
smoke = precache_model("sprites/steam1.spr")
}


VEN 11-17-2006 05:18

Re: Need help generating smoke
 
dutchmeat: reread what i said before.
Also your methods very inefficient.

dutchmeat 11-17-2006 05:29

Re: Need help generating smoke
 
Edited,
and what do you mean by inefficient?

VEN 11-17-2006 05:44

Re: Need help generating smoke
 
This article will tell you in details http://wiki.amxmodx.org/index.php/Optimizing_Plugins

hip_hop_x 11-17-2006 17:45

Re: Need help generating smoke
 
Tommorow when I'll get home I'll try what VEN suggested to me. If I'll have problems I'll post a reply.


All times are GMT -4. The time now is 06:56.

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