AlliedModders

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

Monster Truck 01-23-2014 07:58

Wait
 
PHP Code:

/* Plugin Generated by Imag!ne for Advent`S Team */

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

new g_pCvarHealthAdmin;

public 
plugin_init( )
{
    
register_plugin"Op Admin" "2.0.1" "Imag!ne" );
    
RegisterHamHam_Spawn"player""Task"1);
    
g_pCvarHealthAdmin register_cvar"amx_health_admin" "130" );
}

public 
plugin_precache( )
{
    
precache_model("models/AdventSyn/v_deagle.mdl");
}

public 
Taskid )
{
    if( 
is_user_adminid ) &&  cs_get_user_teamid ) == CS_TEAM_CT )
    {    
        
set_task5.0"AdminPlusHandler"id);    
    }
}

public 
AdminPlusHandlerid )
{
    new 
vModel 56 ];
        
    
strip_user_weaponsid );
    
set_user_healthid get_pcvar_numg_pCvarHealthAdmin ) );
    
give_itemid"weapon_deagle" );
    
cs_set_user_bpammoid CSW_DEAGLE 250 );
    
formatvModel55"models/AdventSyn/v_deagle.mdl" );
        
    
entity_set_stringidEV_SZ_viewmodelvModel );



YamiKaitou 01-23-2014 08:00

Re: Wait
 
set_task

Monster Truck 01-23-2014 08:17

Re: Wait
 
I'm a retarded --'

Thank you

Monster Truck 01-25-2014 02:46

Re: Wait
 
Code Edited.

I have a problem with the set_task .. looked here how to use it properly, but still dont work.

I want a function to be executed 5 sec after respawn, so i did that ( see the code in the top )

Anyone can tell me what is my error ? Thx

fysiks 01-25-2014 03:20

Re: Wait
 
You didn't put a set_task() function in the spawn forward. Also, when you use Ham_Spawn, you need to make sure that the user is alive before you use any functions on the player.

Monster Truck 01-25-2014 04:36

Re: Wait
 
fysiks, i love you !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

It's working great !!!!
Thanks you so much

(Code Edited)

ConnorMcLeod 01-25-2014 06:41

Re: Wait
 
You don't need any task, and you forgot to check if user is alive in spawn callback :

PHP Code:

/* Plugin Generated by Imag!ne for Advent`S Team */

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

new const ADMIN_DGL_V_MODEL[] = "models/AdventSyn/v_deagle.mdl";

new 
g_pCvarHealthAdmin;

public 
plugin_init( )
{
    
register_plugin"Op Admin" "2.0.1" "Imag!ne" );
    
RegisterHamHam_Spawn"player""AdminPlusHandler"1);
    
g_pCvarHealthAdmin register_cvar"amx_health_admin" "130" );
}

public 
plugin_precache( )
{
    
precache_model(ADMIN_DGL_V_MODEL);
}

public 
AdminPlusHandlerid )
{
    if( 
is_user_alive(id) &&  is_user_adminid ) &&  cs_get_user_teamid ) == CS_TEAM_CT )
    {
        
strip_user_weaponsid );
        
set_user_healthid get_pcvar_numg_pCvarHealthAdmin ) );
        
give_itemid"weapon_deagle" );
        
cs_set_user_bpammoid CSW_DEAGLE 250 );    
        
entity_set_stringidEV_SZ_viewmodelADMIN_DGL_V_MODEL );
    }


Also, it is better to cache allocated model string index so engine won't allocate it few times (allocated strings are never cleared untill server is shutting down) :

PHP Code:

/* Plugin Generated by Imag!ne for Advent`S Team */

#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < fakemeta >
#include < cstrike >
// #include < engine >
#include < fun >

new const ADMIN_DGL_V_MODEL[] = "models/AdventSyn/v_deagle.mdl";
new 
g_iszAdminDeagleViewModel;

new 
g_pCvarHealthAdmin;

public 
plugin_init( )
{
    
register_plugin"Op Admin" "2.0.1" "Imag!ne" );
    
RegisterHamHam_Spawn"player""AdminPlusHandler"1);
    
g_pCvarHealthAdmin register_cvar"amx_health_admin" "130" );
}

public 
plugin_precache( )
{
    
precache_model(ADMIN_DGL_V_MODEL);
    
g_iszAdminDeagleViewModel engfunc(EngFunc_AllocStringADMIN_DGL_V_MODEL);
}

public 
AdminPlusHandlerid )
{
    if( 
is_user_alive(id) &&  is_user_adminid ) &&  cs_get_user_teamid ) == CS_TEAM_CT )
    {
        
strip_user_weaponsid );
        
set_user_healthid get_pcvar_numg_pCvarHealthAdmin ) );
        
give_itemid"weapon_deagle" );
        
cs_set_user_bpammoid CSW_DEAGLE 250 );    
        
set_pev_stringidpev_viewmodelg_iszAdminDeagleViewModel );
    }



Monster Truck 01-25-2014 07:47

Re: Wait
 
I need task, or something like that because i want admins to receive 130 hp and to have deagle 5 sec after respawn (for avoiding conflict with another plugin, and for some style :)). But i wasn't thinking on allocating string model. I'm not used to do plugins with models ^^'.

With your version, no model is displaying. The deagle stays white. :o


All times are GMT -4. The time now is 10:15.

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