AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pfn_spawn - NEED HELP (https://forums.alliedmods.net/showthread.php?t=49801)

Killhim 01-13-2007 06:50

pfn_spawn - NEED HELP
 
Hello! I've found this function:
Code:

public pfn_spawn(entid)
{
    if(!is_valid_ent(entid)) return PLUGIN_CONTINUE
    new class[51]
    entity_get_string(entid,EV_SZ_classname,class,50)
    if(equali(class,"hostage_entity"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }
    if(equali(class,"func_hostage_rescue"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }
    if(equal(class,"func_bomb_target"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }
    if(equal(class,"info_bomb_target"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    if(equal(class,"func_escapezone"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    if(equal(class,"func_vip_safteyzone"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    if(equal(class,"func_vip_start"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    return PLUGIN_CONTINUE
}

And I want to use it for the CTF mod on my server. The problem is that I've made a vote system to toogle on/off the ctf mod, so I can't keep it completly on or completly off. I want to know if there is a way to toggle this function on/off ?

Salepate 01-13-2007 06:59

Re: pfn_spawn - NEED HELP
 
Code:
if (get_cvar_num("sv_ctf_mode") == 0)     return PLUGIN_HANDLED

is that what you want ?

Killhim 01-13-2007 13:07

Re: pfn_spawn - NEED HELP
 
Hum. Going to test it right now


Killhim 01-13-2007 13:37

Re: pfn_spawn - NEED HELP
 
I don't get why, but still not working.
Code:

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

public plugin_init()
{
    register_plugin ( "No objectives", "0.1a", "Killhim" );
}
public pfn_spawn(entid)
{
    if (get_cvar_num("ctf_enabled") == 0)
    {
            return PLUGIN_CONTINUE //PLUGIN_HANDLED is making my server crash (it's just a bad usage of it)
    }
    if(!is_valid_ent(entid)) return PLUGIN_HANDLED
    new class[51]
    entity_get_string(entid,EV_SZ_classname,class,50)
    if(equali(class,"hostage_entity"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }
    if(equali(class,"func_hostage_rescue"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }
    if(equal(class,"func_bomb_target"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }
    if(equal(class,"info_bomb_target"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    if(equal(class,"func_escapezone"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    if(equal(class,"func_vip_safteyzone"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    if(equal(class,"func_vip_start"))
    {
        remove_entity(entid)
        return PLUGIN_HANDLED
    }   
    return PLUGIN_CONTINUE
}

That is the code of the plugin I'm trying to write. Still doesn't work. Help me please.

(Actually what this is doing is NOTHING. Seems like this function can't acess to cvars...)

sawce 01-13-2007 15:05

Re: pfn_spawn - NEED HELP
 
... the cvar doesnt exist

Salepate 01-13-2007 16:56

Re: pfn_spawn - NEED HELP
 
Of Course, you have to create the var

in plugin_init();
Code:
if (!cvar_exists("sv_ctf_mode"))     register_cvar("sv_ctf_mode","0");

Killhim 01-13-2007 19:18

Re: pfn_spawn - NEED HELP
 
Quote:

Originally Posted by sawce (Post 426767)
... the cvar doesnt exist

Tell me if I'm wrong, but I think this cvar is registered and exists. It's created in ghw_ctf.amxx:
Code:

register_cvar(cvar_ctf_enabled,"0")
:cry::cry::cry::cry::cry::cry:

Salepate 01-13-2007 19:31

Re: pfn_spawn - NEED HELP
 
then use cvar_ctf_enabled instead of sv_ctf_mode. :) (and it will work) don't forget to use [small ][/small ] next time

Killhim 01-14-2007 02:32

Re: pfn_spawn - NEED HELP
 
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #include <engine> public plugin_init() {         register_plugin ( "No objectives", "0.1a", "Killhim" );     if (!cvar_exists("cvar_ctf_enabled"))     {             register_cvar("cvar_ctf_enabled","1");     } } public pfn_spawn(entid) {     if (get_cvar_num("cvar_ctf_enabled") == 0)     {             return PLUGIN_CONTINUE     }     if(!is_valid_ent(entid)) return PLUGIN_HANDLED     new class[51]     entity_get_string(entid,EV_SZ_classname,class,50)     if(equali(class,"hostage_entity"))     {         remove_entity(entid)         return PLUGIN_HANDLED     }     if(equali(class,"func_hostage_rescue"))     {         remove_entity(entid)         return PLUGIN_HANDLED     }     if(equal(class,"func_bomb_target"))     {         remove_entity(entid)         return PLUGIN_HANDLED     }     if(equal(class,"info_bomb_target"))     {         remove_entity(entid)         return PLUGIN_HANDLED     }         if(equal(class,"func_escapezone"))     {         remove_entity(entid)         return PLUGIN_HANDLED     }         if(equal(class,"func_vip_safteyzone"))     {         remove_entity(entid)         return PLUGIN_HANDLED     }         if(equal(class,"func_vip_start"))     {         remove_entity(entid)         return PLUGIN_HANDLED     }         return PLUGIN_CONTINUE }
Still not working... :S:S:S Well if no one can help me for this, is there an other way to make never-endings rounds? Thx guys, I really need this!:mrgreen:

teame06 01-14-2007 02:35

Re: pfn_spawn - NEED HELP
 
The forward pfn_spawn is called before plugin_init.

So your going to have to register the cvar in plugin_precache but it always going to be set to 1 on first server load.


All times are GMT -4. The time now is 22:25.

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