AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with sprite (https://forums.alliedmods.net/showthread.php?t=282667)

wEEk 05-13-2016 22:14

Help with sprite
 
Can edit the shape of sprites to show this form of ZP ?

PHP Code:

#include <amxmodx>  
#include <fakemeta>  
#include <engine> 

new ts_win_spritect_win_sprite

public plugin_precache() 

    
ct_win_sprite precache_model("sprites/human_win.spr"
    
ts_win_sprite precache_model("sprites/zombie_win.spr" 


public 
plugin_init() 
{         
    
register_plugin("Round End Sprites Effect""1.1""Krtola"
    
    
register_event("SendAudio""t_win""a""2&%!MRAD_terwin"
    
register_event("SendAudio""ct_win""a""2&%!MRAD_ctwin")     


public 
t_win() 

    static 
id
    for(
id id <= get_maxplayers() ; id++) 
    { 
        if(!
is_user_connected(id)) 
            continue; 
        
        
zombies_win_Effects(id
    } 


public 
ct_win() 

    static 
id
    for(
id id <= get_maxplayers() ; id++) 
    { 
        if(!
is_user_connected(id)) 
            continue; 
        
        
humans_win_Effects(id
    } 


public 
humans_win_Effects(id
{     
    new 
FloatHumanOrigin
    
entity_get_vectoridEV_VEC_originHumanOrigin 
    
engfuncEngFunc_MessageBeginMSG_ONE_UNRELIABLESVC_TEMPENTITYHumanOriginid
    
write_byteTE_SPRITETRAIL )     
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] + 200
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] + 200 
    
write_shortct_win_sprite )  
    
write_byte)  
    
write_byte30 
    
write_byte)  
    
write_byte75 
    
write_byte70 
    
message_end( ) 


public 
zombies_win_Effects(id
{     
    new 
FloatHumanOrigin
    
entity_get_vectoridEV_VEC_originHumanOrigin 
    
engfuncEngFunc_MessageBeginMSG_ONE_UNRELIABLESVC_TEMPENTITYHumanOriginid
    
write_byteTE_SPRITETRAIL )     
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] + 200
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] ) 
    
engfuncEngFunc_WriteCoordHumanOrigin] + 200 
    
write_shortts_win_sprite )  
    
write_byte)  
    
write_byte30 
    
write_byte)  
    
write_byte75 
    
write_byte70 
    
message_end( ) 


Form zombie plague ->

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <xs>

// Distance at which the sprite is placed from the users screen
// DO NOT EDIT UNNECESSARILY!
#define DISTANCE     12

new g_player_ent[33], g_bit_connected_userg_stop_frame[33]

// Connected players macros
#define player_is_connected(%1)        (g_bit_connected_user |=  (1 << (%1 & 31)))
#define player_disconnected(%1)        (g_bit_connected_user &= ~(1 << (%1 & 31)))
#define is_player_connected(%1)        ((1 <= %1 <= 32) && (g_bit_connected_user & (1 << (%1 & 31))))

public plugin_init() 
{
    
// Register the plugin and the main forward
    
register_plugin("[ZP] Addon: Sprites On HUD""1.0""@bdul!");
    
register_forward(FM_AddToFullPack"fm_add_to_fullpack"1)
}

public 
plugin_natives()
{
    
// Lets register some natives
    
register_native("zp_display_hud_sprite""native_display_hud_sprite"1)
    
register_native("zp_remove_hud_sprite""native_remove_hud_sprite"1)
}

public 
fm_add_to_fullpack(eseenthosthost_flagsplayerp_set)
{
    
// Valid player ?
    
if (!is_player_connected(host))
        return 
FMRES_IGNORED;
    
    
// Player haves a valid sprite entity
    
if (ent == g_player_ent[host])
    {
        static 
Float:origin[3], Float:forvec[3], Float:voffsets[3]
        
        
// Retrieve player's origin
        
pev(hostpev_originorigin)
        
pev(hostpev_view_ofsvoffsets)
        
xs_vec_add(originvoffsetsorigin)
        
        
// Get a forward vector in the direction of player's aim
        
velocity_by_aim(hostDISTANCEforvec)
        
        
// Set the sprite on the new origin
        
xs_vec_add(originforvecorigin)
        
engfunc(EngFunc_SetOriginentorigin)
        
set_es(esES_Originorigin)
        
        
// Make the sprite visible
        
set_es(esES_RenderModekRenderNormal)
        
set_es(esES_RenderAmt200)
        
        
// Sprite animation already stopped ?
        
if (!g_stop_frame[host])
            return 
FMRES_IGNORED
        
        
// Stop the animation at the desired frame
        
if (pev(entpev_frame) == g_stop_frame[host])
        {
            
set_pev(entpev_framerate0.0)
            
g_stop_frame[host] = 0
        
}
    }
    
    
// Stupid compiler !!
    
return FMRES_IGNORED
}

public 
client_putinserver(id)
{
    
// Player connected
    
player_is_connected(id)
    
    
// Marks bots as disconnected players (so sprites are'nt displayed to them)
    
if (is_user_bot(id)) player_disconnected(id)
    
    
// Remove sprite entity if present
    
if (pev_valid(g_player_ent[id]))
        
remove_sprite_entity(id)
}

public 
client_disconnect(id)
{
    
// Player disconnected
    
player_disconnected(id)
    
    
// Remove sprite entity if present
    
if (pev_valid(g_player_ent[id]))
        
remove_sprite_entity(id)
}

public 
native_display_hud_sprite(id, const sprite_name[], Float:sprite_sizesprite_stopframeFloat:sprite_framerate)
{
    
// Invalid player ?
    
if (!is_player_connected(id))
        return -
1;
    
    
// Already haves a sprite on his hud
    
if (g_player_ent[id])
        return -
1;
    
    
// Strings passed byref
    
param_convert(2)
    
    
// Invalid sprite ?
    
if (!sprite_name[0])
        return -
1;
    
    
// Create an entity for the player
    
g_player_ent[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_sprite"))
    
    
// Invalid entity ?
    
if (!pev_valid(g_player_ent[id]))
        return -
1;
    
    
// Set some basic properties
    
set_pev(g_player_ent[id], pev_takedamage0.0)
    
set_pev(g_player_ent[id], pev_solidSOLID_NOT)
    
set_pev(g_player_ent[id], pev_movetypeMOVETYPE_NONE)
    
    
// Set the sprite model
    
engfunc(EngFunc_SetModelg_player_ent[id], sprite_name)
    
    
// Set the rendering on the entity
    
set_pev(g_player_ent[id], pev_rendermodekRenderTransAlpha)
    
set_pev(g_player_ent[id], pev_renderamt0.0)
    
    
// Set the sprite size
    
set_pev(g_player_ent[id], pev_scalesprite_size)
    
    
// Update sprite's stopping frame
    
g_stop_frame[id] = sprite_stopframe
    
    
// Allow animation of sprite ?
    
if (g_stop_frame[id] && sprite_framerate 0.0)
    {
        
// Set the sprites animation time, framerate and stop frame
        
set_pev(g_player_ent[id], pev_animtimeget_gametime())
        
set_pev(g_player_ent[id], pev_frameratesprite_framerate)
        
        
// Spawn the sprite entity (necessary to play the sprite animations)
        
set_pev(g_player_ent[id], pev_spawnflagsSF_SPRITE_STARTON)
        
dllfunc(DLLFunc_Spawng_player_ent[id])
    }
    
    return 
g_player_ent[id];
}

public 
native_remove_hud_sprite(id)
{
    
// Invalid player ?
    
if (!is_player_connected(id))
        return -
1;
    
    
// Doesnt haves any sprite on his screen ?
    
if (!pev_valid(g_player_ent[id]))
        return -
1;
    
    
// Remove sprite entity
    
remove_sprite_entity(id)
    
    return 
1;
}

// Removes a sprite entity from world
remove_sprite_entity(id)
{
    
engfunc(EngFunc_RemoveEntityg_player_ent[id])
    
    
g_player_ent[id] = 0
    g_stop_frame
[id] = 0




All times are GMT -4. The time now is 18:43.

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