Raised This Month: $ Target: $400
 0% 

I need help for save stings in array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
s.valdenegro
BANNED
Join Date: Apr 2013
Old 04-24-2013 , 20:30   I need help for save stings in array
Reply With Quote #1

Dear friends of AlliedModders:

I search plugins for choose models and i found this:
PHP Code:
#include <amxmodx>
#include <zombieplague>
#include <fakemeta>
#include <fun>

new g_ent_playermodel[33];
new 
g_ent_weaponmodel[33];
new 
g_currentweapon[33];
new 
g_pcvar_active;
new 
player_model_c[33];
new 
MenuKeys = (<< 0) + (<< 1) + (<< 2) + (<< 3) + (<< 4) + (<< 5) + (<< 6) + (<< 7) + (<< 8)+ (<< 9)
new 
BuyMenuBodyText[256]

public 
plugin_init()
{
    
register_plugin("[ZP] Select Models""1.2""Anggara_nothing")
    
g_pcvar_active register_cvar("zp_sem_enable""1")
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
    
SetupSelectMenu()
    
register_clcmd("say /models""ClCmdSelectModel")
    
register_menucmd(register_menuid("\rSelect your model:"), MenuKeys"SelectIt")
}

public 
plugin_precache()
{
    
// Change your models here.
    
engfunc(EngFunc_PrecacheModel"models/player/cool_girl/cool_girl.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/cool_guy/cool_guy.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/grey/grey.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/leon/leon.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/leet/leet.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/sas/sas.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/terror/terror.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/urban/urban.mdl")
}

// Current Weapon info
public message_cur_weapon(msg_idmsg_destmsg_entity)
{
    
// Player not alive or not an active weapon
    
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
        return;
    
    
// Get weapon id
    
static weapon
    weapon 
get_msg_arg_int(2)
    
    
// Store weapon id for reference
    
g_currentweapon[msg_entity] = weapon
    
    
// Replace weapon models with custom ones
    
fm_set_weaponmodel_ent(msg_entity)
}

// User Infected forward
public zp_user_infected_post(idinfector)
{
    
// remove the glow.
    
set_user_rendering(idkRenderFxNone0,0,0,kRenderNormal255)
    
    
// Remove Custom Model Entities
    
fm_remove_model_ents(id)
}

public 
ClCmdSelectModel(id)
{
    if(
zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id))
    {
        
client_print(idprint_chat"This is just for human.")

        
set_hudmessage(2001550, -1.00.5006.08.00.30.53)
        
show_hudmessage(id"This is just for human.")
        return 
PLUGIN_HANDLED;
    }
    else if(!
get_pcvar_num(g_pcvar_active))
    {
        
set_hudmessage(2001550, -1.00.5006.08.00.30.53)
        
show_hudmessage(id"This ability has been disabled.")
        return 
PLUGIN_HANDLED;
    }
    else if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"You must alive before using this.")

        
set_hudmessage(2001550, -1.00.5006.08.00.30.53)
        
show_hudmessage(id"You must alive before using this.")
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
SetupSelectMenu()
        
show_menu(idMenuKeysBuyMenuBodyText)
    }
    return 
PLUGIN_CONTINUE;
}

public 
SelectIt(idkey)
{
    switch (
key)
    {
        case 
0:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/cool_girl/cool_girl.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id][] = "models/player/cool_girl/cool_girl.mdl"
            
}
        }
        case 
1:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/cool_guy/cool_guy.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id] = "models/player/cool_guy/cool_guy.mdl"
            
}
        }
        case 
2:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/grey/grey.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id] = "models/player/grey/grey.mdl"
            
}
        }
        case 
3:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/leon/leon.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id] = "models/player/leon/leon.mdl"
            
}
        }
        case 
4:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/leet/leet.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id] = "models/player/leet/leet.mdl"
            
}
        }
        case 
5:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/sas/sas.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id] = "models/player/sas/sas.mdl"
            
}
        }
        case 
6:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/terror/terror.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id] = "models/player/terror/terror.mdl"
            
}
        }
        case 
7:
        {
            
fm_remove_model_ents(id)
            if (!
pev_valid(g_ent_playermodel[id]))
            {
                
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                if (!
pev_valid(g_ent_playermodel[id])) return ;
                
                
set_user_rendering(idkRenderFxNone255255255kRenderTransTexture1)
                
set_pev(g_ent_playermodel[id], pev_classname"player_model")
                
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_ent_playermodel[id], pev_aimentid)
                
set_pev(g_ent_playermodel[id], pev_ownerid)
                
// and change this.
                
engfunc(EngFunc_SetModelg_ent_playermodel[id], "models/player/urban/urban.mdl")
                
fm_set_weaponmodel_ent(id)
                
//player_model_c[id] = "models/player/urban/urban.mdl"
            
}
        }
        case 
9: return ;
    }
    
    
ClCmdSelectModel(id)
    return;
}

public 
SetupSelectMenu()
{
    new 
menuLen format(BuyMenuBodyText255"\rSelect your model:^n^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w1. Cool Girl^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w2. Cool Guy^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w3. Grey^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w4. Leon^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w5. leet^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w6. sas^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w7. terror^n")
    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w8. urban^n^n")

    
menuLen += format(BuyMenuBodyText[menuLen], 255 menuLen"\w0. Exit")

    return 
1
}

// Remove Custom Model Entities
stock fm_remove_model_ents(id)
{
    
// Remove "playermodel" ent if present
    
if (pev_valid(g_ent_playermodel[id]))
    {
        
engfunc(EngFunc_RemoveEntityg_ent_playermodel[id])
        
g_ent_playermodel[id] = 0
    
}
    
// Remove "weaponmodel" ent if present
    
if (pev_valid(g_ent_weaponmodel[id]))
    {
        
engfunc(EngFunc_RemoveEntityg_ent_weaponmodel[id])
        
g_ent_weaponmodel[id] = 0
    
}
}

// Set Weapon Model on Entity
stock fm_set_weaponmodel_ent(id)
{
    
// Get player's p_ weapon model
    
static model[100]
    
pev(idpev_weaponmodel2modelsizeof model 1)
    
    
// Set model on entity or make a new one if unexistant
    
if (!pev_valid(g_ent_weaponmodel[id]))
    {
        
g_ent_weaponmodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
        if (!
pev_valid(g_ent_weaponmodel[id])) return;
        
        
set_pev(g_ent_weaponmodel[id], pev_classname"weapon_model")
        
set_pev(g_ent_weaponmodel[id], pev_movetypeMOVETYPE_FOLLOW)
        
set_pev(g_ent_weaponmodel[id], pev_aimentid)
        
set_pev(g_ent_weaponmodel[id], pev_ownerid)
    }
    
    
engfunc(EngFunc_SetModelg_ent_weaponmodel[id], model)
}


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 
I have error to save the string in the array position and i dont know how to initialize all the position of the array before the plugin_init(). I need help for this because in my server zombie plague all the models for the player are choise randomly.
If somebody know a best way than this for do this helpme.
The comentaries contain something that i wanna do.
Sorry for my bad english i speak spanish and sorry if this post have to be in other subforum
This is my first post

Last edited by s.valdenegro; 04-24-2013 at 20:31. Reason: Confusion
s.valdenegro is offline
Reply


Thread Tools
Display Modes

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 10:50.


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