Raised This Month: $ Target: $400
 0% 

2 more little problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-26-2011 , 13:22   2 more little problems
Reply With Quote #1

so...i have this plugin
i've tried to make it set a cvar's value to 7 on round end and then restore it on round start (variable nvg_radius)
but it doesn't work...it doesn't set the radius back to normal on round start
and the second problem is that sometimes, the hand model doesn't change back on round start either
here's the code...please help
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

new Hands[33], RandomMaxPlayersChekUserHandsSetNVision

// Normal Models
new const MODELS[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win.mdl",
    
"models/zombie_plague/human_win.mdl"
}

new const 
MODELS2[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win_2.mdl",
    
"models/zombie_plague/human_win_2.mdl"
}

// Fliped Models
new const MODELS_FLIP[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win-f.mdl",
    
"models/zombie_plague/human_win-f.mdl"
}

new const 
MODELS_FLIP2[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win-f_2.mdl",
    
"models/zombie_plague/human_win-f_2.mdl"
}


new 
g_iModelIndex[3], g_iModelIndexFlip[3], g_iModelIndex2[3], g_iModelIndexFlip2[3], g_iWinTeamnvg_radius

public plugin_init()
{
    
register_plugin("[ZP] Sub-Plugin: New Win Messages""1.4""Shidla / xPaw / 93()|29!/<" )
    
register_event("HLTV""EventRoundStart""a""1=0""2=0" )
    
register_event("CurWeapon""EventCurWeapon""be""1=1")

    
MaxPlayers get_maxplayers()

    
register_cvar("Shidla""[ZP] Sub-Plugin: New Win Messages v.1.4"FCVAR_SERVER|FCVAR_SPONLY)
    
register_cvar("zp_new_win_messages""[ZP] Sub-Plugin: New Win Messages v.1.4"FCVAR_SERVER|FCVAR_SPONLY)

    
ChekUserHands register_cvar("zp_new_win_msg_chek" "1")
    
SetNVision register_cvar("zp_new_win_msg_set_nvision" "1")
}

public 
plugin_precache()
{
    for (new 
WIN_ZOMBIES<= WIN_HUMANSi++)
    {
        
// Normal Models
        
precache_model(MODELS[i])
        
g_iModelIndex[i] = engfunc(EngFunc_AllocStringMODELS[i])
        
precache_model(MODELS2[i])
        
g_iModelIndex2[i] = engfunc(EngFunc_AllocStringMODELS2[i])

        
// Fliped Models
        
precache_model(MODELS_FLIP[i])
        
g_iModelIndexFlip[i] = engfunc(EngFunc_AllocStringMODELS_FLIP[i])
        
precache_model(MODELS_FLIP2[i])
        
g_iModelIndexFlip2[i] = engfunc(EngFunc_AllocStringMODELS_FLIP2[i])
    }
}

public 
client_connect(id)
{
    if(!
is_user_bot(id) && get_pcvar_num (ChekUserHands))
        
query_client_cvar(id "cl_righthand" "Hands_CVAR_Value")
}

public 
Hands_CVAR_Value(id, const cvar[], const value[])
{
    if((
<= id <= MaxPlayers) && get_pcvar_num (ChekUserHands))    // Bug Fix & Cheking
        
Hands[id] = str_to_num(value)
}

public 
client_disconnect(id)
{
    if(
get_pcvar_num (ChekUserHands))
        
Hands[id] = 0
}

public 
zp_round_ended(iTeam)
{
    if (
iTeam == WIN_NO_ONE)
        return
    
    
g_iWinTeam iTeam
    
new iPlayers[32], iNum
    get_players
(iPlayersiNum"ch")

    
Random random_num(1)
    for (new 
iiNumi++)
    {
        if(
get_pcvar_num (ChekUserHands))
            
client_cmd(iPlayers[i], "cl_righthand ^"1^"")

        if(
get_pcvar_num(SetNVision))
        {
            
nvg_radius get_cvar_num("zp_nvg_size")
            
set_cvar_num("zp_nvg_size"7)
            
            
zp_set_user_nightvision(iPlayers[i], 1)
        }
        
        switch(
Random)
        {
            case 
0:
            {
                if (
get_user_weapon(iPlayers[i]) != CSW_KNIFE)
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndexFlip[iTeam])
                else
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndex[iTeam])
            }

            case 
1:
            {
                if (
get_user_weapon(iPlayers[i]) != CSW_KNIFE)
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndexFlip2[iTeam])
                else
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndex2[iTeam])
            }
        }
    }
}

public 
EventRoundStart()
{
    
g_iWinTeam WIN_NO_ONE
    
    
if (get_cvar_num("zp_nvg_size") != nvg_radius)
        
set_cvar_num("zp_nvg_size"nvg_radius)
    
    if(
get_pcvar_num (ChekUserHands))
    {
        for (new 
1<= MaxPlayersi++)
        {
            if(!
is_user_connected(i))
                continue        
// xPaw fix)))

            
client_cmd(i"cl_righthand ^"%d^""Hands[i])
        }
    }
}

public 
EventCurWeapon(const id)
{
    if (
g_iWinTeam WIN_NO_ONE)
    {
        if (
get_pcvar_num (ChekUserHands))
            
client_cmd(id"cl_righthand ^"1^"")

        switch(
Random)
        {
            case 
0:
            {
                if (
get_user_weapon(id) != CSW_KNIFE)
                    
set_pev(idpev_viewmodelg_iModelIndexFlip[g_iWinTeam])
                else
                    
set_pev(idpev_viewmodelg_iModelIndex[g_iWinTeam])
            }

            case 
1:
            {
                if (
get_user_weapon(id) != CSW_KNIFE)
                    
set_pev(idpev_viewmodelg_iModelIndexFlip2[g_iWinTeam])
                else
                    
set_pev(idpev_viewmodelg_iModelIndex2[g_iWinTeam])
            }
        }
    }

Attached Files
File Type: sma Get Plugin or Get Source (zp_new_win_msg_1.4.sma - 534 views - 5.0 KB)
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-26-2011 , 15:08   Re: 2 more little problems
Reply With Quote #2

About cvar - try this:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

new Hands[33], RandomMaxPlayersChekUserHandsSetNVision
new BLAAAAAAAAAAARRRRRRRGGGGGHHHHHH

// Normal Models
new const MODELS[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win.mdl",
    
"models/zombie_plague/human_win.mdl"
}

new const 
MODELS2[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win_2.mdl",
    
"models/zombie_plague/human_win_2.mdl"
}

// Fliped Models
new const MODELS_FLIP[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win-f.mdl",
    
"models/zombie_plague/human_win-f.mdl"
}

new const 
MODELS_FLIP2[3][] =
{
    
"",
    
"models/zombie_plague/zombie_win-f_2.mdl",
    
"models/zombie_plague/human_win-f_2.mdl"
}


new 
g_iModelIndex[3], g_iModelIndexFlip[3], g_iModelIndex2[3], g_iModelIndexFlip2[3], g_iWinTeamnvg_radius

public plugin_init()
{
    
register_plugin("[ZP] Sub-Plugin: New Win Messages""1.4""Shidla / xPaw / 93()|29!/<" )
    
register_event("HLTV""EventRoundStart""a""1=0""2=0" )
    
register_event("CurWeapon""EventCurWeapon""be""1=1")

    
MaxPlayers get_maxplayers()

    
register_cvar("Shidla""[ZP] Sub-Plugin: New Win Messages v.1.4"FCVAR_SERVER|FCVAR_SPONLY)
    
register_cvar("zp_new_win_messages""[ZP] Sub-Plugin: New Win Messages v.1.4"FCVAR_SERVER|FCVAR_SPONLY)

    
ChekUserHands register_cvar("zp_new_win_msg_chek" "1")
    
SetNVision register_cvar("zp_new_win_msg_set_nvision" "1")
    
BLAAAAAAAAAAARRRRRRRGGGGGHHHHHH get_cvar_pointer("zp_nvg_size")
}

public 
plugin_precache()
{
    for (new 
WIN_ZOMBIES<= WIN_HUMANSi++)
    {
        
// Normal Models
        
precache_model(MODELS[i])
        
g_iModelIndex[i] = engfunc(EngFunc_AllocStringMODELS[i])
        
precache_model(MODELS2[i])
        
g_iModelIndex2[i] = engfunc(EngFunc_AllocStringMODELS2[i])

        
// Fliped Models
        
precache_model(MODELS_FLIP[i])
        
g_iModelIndexFlip[i] = engfunc(EngFunc_AllocStringMODELS_FLIP[i])
        
precache_model(MODELS_FLIP2[i])
        
g_iModelIndexFlip2[i] = engfunc(EngFunc_AllocStringMODELS_FLIP2[i])
    }
}

public 
client_connect(id)
{
    if(!
is_user_bot(id) && get_pcvar_num (ChekUserHands))
        
query_client_cvar(id "cl_righthand" "Hands_CVAR_Value")
}

public 
Hands_CVAR_Value(id, const cvar[], const value[])
{
    if((
<= id <= MaxPlayers) && get_pcvar_num (ChekUserHands))    // Bug Fix & Cheking
        
Hands[id] = str_to_num(value)
}

public 
client_disconnect(id)
{
    if(
get_pcvar_num (ChekUserHands))
        
Hands[id] = 0
}

public 
zp_round_ended(iTeam)
{
    if (
iTeam == WIN_NO_ONE)
        return
    
    
g_iWinTeam iTeam
    
new iPlayers[32], iNum
    get_players
(iPlayersiNum"ch")

    
Random random_num(1)
    for (new 
iiNumi++)
    {
        if(
get_pcvar_num (ChekUserHands))
            
client_cmd(iPlayers[i], "cl_righthand ^"1^"")

        if(
get_pcvar_num(SetNVision))
        {
            
nvg_radius get_pcvar_num(BLAAAAAAAAAAARRRRRRRGGGGGHHHHHH)
            
set_pcvar_num(BLAAAAAAAAAAARRRRRRRGGGGGHHHHHH7)
            
            
zp_set_user_nightvision(iPlayers[i], 1)
        }
        
        
client_print(idprint_chat"ZP_ROUND_END - changing hand model")

        switch(
Random)
        {
            case 
0:
            {
                if (
get_user_weapon(iPlayers[i]) != CSW_KNIFE)
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndexFlip[iTeam])
                else
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndex[iTeam])
            }

            case 
1:
            {
                if (
get_user_weapon(iPlayers[i]) != CSW_KNIFE)
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndexFlip2[iTeam])
                else
                    
set_pev(iPlayers[i], pev_viewmodelg_iModelIndex2[iTeam])
            }
        }
    }
}

public 
EventRoundStart()
{
    
g_iWinTeam WIN_NO_ONE
    set_pcvar_num
(BLAAAAAAAAAAARRRRRRRGGGGGHHHHHHnvg_radius)
    
    if(
get_pcvar_num (ChekUserHands))
    {
        for (new 
1<= MaxPlayersi++)
        {
            if(!
is_user_connected(i))
                continue        
// xPaw fix)))

            
client_cmd(i"cl_righthand ^"%d^""Hands[i])
        }
    }
}

public 
EventCurWeapon(const id)
{
    if (
g_iWinTeam WIN_NO_ONE)
    {
        
client_print(idprint_chat"curweapon - changing hand model...")
    
        if (
get_pcvar_num (ChekUserHands))
            
client_cmd(id"cl_righthand ^"1^"")

        switch(
Random)
        {
            case 
0:
            {
                if (
get_user_weapon(id) != CSW_KNIFE)
                    
set_pev(idpev_viewmodelg_iModelIndexFlip[g_iWinTeam])
                else
                    
set_pev(idpev_viewmodelg_iModelIndex[g_iWinTeam])
            }

            case 
1:
            {
                if (
get_user_weapon(id) != CSW_KNIFE)
                    
set_pev(idpev_viewmodelg_iModelIndexFlip2[g_iWinTeam])
                else
                    
set_pev(idpev_viewmodelg_iModelIndex2[g_iWinTeam])
            }
        }
    }

About model - I added some messages. Check if this message still appears if no model change needed - if it does, re-check your if conditions.
...
In fact, I don't see any code that changes model back on round start.
__________________


Last edited by SonicSonedit; 04-26-2011 at 15:13.
SonicSonedit is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-26-2011 , 17:54   Re: 2 more little problems
Reply With Quote #3

Quote:
Originally Posted by SonicSonedit View Post
About cvar - try this:
About model - I added some messages. Check if this message still appears if no model change needed - if it does, re-check your if conditions.
...
In fact, I don't see any code that changes model back on round start.
hmm
why cvar_pointer and not cvar_num?
and how can i change the model back to normal one on round start?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-26-2011 , 18:03   Re: 2 more little problems
Reply With Quote #4

georgik57
Quote:
and how can i change the model back to normal one on round start?
Save original model name in some string by using pev(iPlayers[i], pev_viewmodel, some_string, charsmax(some_string)) and then restore it in public EventRoundStart()
__________________


Last edited by SonicSonedit; 04-26-2011 at 18:08.
SonicSonedit is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-26-2011 , 18:07   Re: 2 more little problems
Reply With Quote #5

Quote:
Originally Posted by SonicSonedit View Post
Save original model name in some string by using pev(iPlayers[i], pev_viewmodel, some_string, charsmax(some_string)) and then restore it in public EventRoundStart()
makes sense
what about this:
Quote:
Originally Posted by georgik57 View Post
hmm
why cvar_pointer and not cvar_num?
?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-26-2011 , 18:08   Re: 2 more little problems
Reply With Quote #6

http://forums.alliedmods.net/showpos...54&postcount=3
__________________

SonicSonedit is offline
Old 04-26-2011, 18:09
georgik57
This message has been deleted by georgik57.
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-26-2011 , 18:41   Re: 2 more little problems
Reply With Quote #7

Quote:
Originally Posted by georgik57 View Post
Quote:
Originally Posted by SonicSonedit View Post
okay got it
will remember that
thank you
if that's true then what is get_cvar_num used for?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-26-2011 , 18:44   Re: 2 more little problems
Reply With Quote #8

Quote:
Originally Posted by georgik57 View Post
if that's true then what is get_cvar_num used for?
You need to learn about how cvar pointers are used and then you should be able to answer your own question.
__________________
fysiks is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-26-2011 , 18:45   Re: 2 more little problems
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
You need to learn about how cvar pointers are used and then you should be able to answer your own question.
i know how to use them
but why to use them and not use cvar_num?
what's the difference?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-26-2011 , 18:56   Re: 2 more little problems
Reply With Quote #10

http://forums.alliedmods.net/showpos...26&postcount=5

and

Quote:
Originally Posted by joaquimandrade View Post
If you say: "daddy please bring me the beer that is in the fridge", your daddy will take more time to find it than if you say "daddy please bring me the beer that is in the second shelf of the fridge, next to the milk". But, don't fool your daddy. Otherwise you can have to drink the milk instead.
The latter is an analogy for cvar pointers. They are more efficient.
__________________
fysiks is offline
Old 04-26-2011, 18:59
georgik57
This message has been deleted by georgik57.
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 04:18.


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