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",
"zombie_source",
"zombie_source",
"zombie_source"
}
new const g_szAcces[][] =
{
"t", //fondator
"x", //owner
"v", //co-owner
"y" //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 i = 0; i < sizeof(g_szHuman); i++) // if you don't know what loops are -> https://wiki.alliedmods.net/Pawn_tutorial#For_Loops
{
formatex(szHuman, charsmax(szHuman), "models/player/%s/%s.mdl", g_szHuman[i], g_szHuman[i]); // format the string with model location to precache it
precache_model(szHuman); // use the string to precache the model
formatex(szZombie, charsmax(szZombie), "models/player/%s/%s.mdl", g_szZombie[i], 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 i = 0; i < sizeof(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 1: cs_set_user_model(id, g_szZombie[i]); // set zombie model if he's zombie
case 0: cs_set_user_model(id, g_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;
}
use [ php ] [ /php ] for code
docs for switch statement:
https://wiki.alliedmods.net/Pawn_tut...tch_Statements