Raised This Month: $ Target: $400
 0% 

Model By Flag for Zombie Escape Mod (problem) !


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-28-2021 , 20:09   Re: Model By Flag for Zombie Escape Mod (problem) !
Reply With Quote #2

First of all, you don't have to use return value in every function because the compiler add return 0 at the end of it.
Personal, i use it after i use return PLUGIN_HANDLED and you are using an old compiler. I recommend you version 1.9

This is how your plugin should look to don't be so hardcoded [NOT TESTED]
PHP Code:
#include <amxmodx>
#include <zombieplague>
#include <cstrike>
#include <hamsandwich>

new const g_szHuman[][] = //using this method is more easy to precache models and you can use loops to check if user has a specific flag
{
    
"fondator_ct",
    
"owner_ct",
    
"co-owner_ct",
    
"head-admin_ct" //and so on
}

new const 
g_szZombie[][] = 
{
    
"zombie_source",
    
"another_skin",
    
"another_skin2",
    
"another_skin3"
}

new const 
g_szAcces[][] =
{
    
"abcdefghjklmnoprsitu"//fondator
    
"abcdefghijklmnopqrsux"//owner
    
"abcdefijmnopqrsuv"//co-owner
    
"abcdefijmnopqy" //head-admin
}

public 
plugin_init() {
    
    
register_plugin("XVSkins †""5.0""oTm4n3")

    
register_logevent("round_start"2"1=Round_Start"// you have to reset players models 
    
    
return PLUGIN_CONTINUE
}

public 
plugin_precache() {
    
    
//create 2 strings
    
new szHuman[64];
    new 
szZombie[64];

    for(new 
0sizeof(g_szHuman); i++) // if you don't know what loops are -> https://wiki.alliedmods.net/Pawn_tutorial#For_Loops
    
{
        
formatex(szHumancharsmax(szHuman), "models/player/%s/%s.mdl"g_szHuman[i]); // format the string with model location to precache it
        
precache_model(szHuman); // use the string to precache the model

        
formatex(szZombiecharsmax(szZombie), "models/player/%s/%s.mdl"g_szZombie[i]); // doing same thing as above for zombies model
        
precache_model(szZombie);
    }
}

public 
round_start(id)
{
    if(
is_user_alive(id))
        
cs_reset_user_model(id);
}

public 
zp_user_infected_post(id// this is a predefinited function from zombieplague library
{
    if(!
is_user_alive(id)) // you must check if the player is alive first of all (every time in situations like this)
        
return PLUGIN_HANDLED;

    for(new 
0sizeof(g_szAcces); i++ )
    {
        if(
get_user_flags(id) & read_flags(g_szAcces[i])) // check if the player has the flag
        
{
            switch(
zp_get_user_zombie(id)) // i didn t find anything about this native, but let's say it will return 1 if player is zombie and 0 if human
            
{
                case 
1cs_set_user_model(idg_szZombie[i]); // set zombie model if he's zombie
                
case 0cs_set_user_model(idg_szHuman[i]); // set human model if he's human
                
default: cs_reset_user_model(id); 
            }
        }
        else 
        {
            
cs_reset_user_model(id); // reset user model if he s not an admin (this can overlap with other plugin that are doing same thing)
        
}
    }

    return 
PLUGIN_CONTINUE;

I recommend you to use this api to set players model: https://forums.alliedmods.net/showthread.php?t=161255

Also, if you model have a T model (model_nameT.mdl) you can do something like this: https://forums.alliedmods.net/showpo...78&postcount=6



i hope i helped you

Last edited by lexzor; 07-28-2021 at 20:19.
lexzor is offline
 



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 02:37.


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