Raised This Month: $ Target: $400
 0% 

Entity Resources Replacement[ V 1.4 ]


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-26-2014 , 13:48   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #41

There is no problem. Since you patch in memory, all data of the lib are basically glue together, that's why you can't go above the original size, because you would overlap on next string for example. When you replace abcd -> ab, you did no change the original boundaries. It's like having [ab__]. So what it matters is the original string size, ab -> abcd should be fine.
__________________
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-16-2014 , 05:45   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #42

Working on a huge update. This will allow you to have dynamic and static configuration. You will have two files that looks like this:

Code:
;This file allow you to dynamically change entites resources
;You can have resources changed for different players, for vips, for maps and so on.
;Here you have multiple types of posibilities

;Change things by SteamId:

;STEAMID
;OLD_RESOURCE NEW_RESOURCE
;You can make than a specific player to have custom skins, to have a custom model and so on.
;If you want to set up a player model please specify PLAYER_MODEL key in front of the model.

;Example:
;STEAM_blablablabla
;PLAYER_MODEL "models/player/new_player_model.mdl"
;"old_weapon_model" "new_weapon_model"

;Change things globally( like for all players ):
 
;PLAYER_MODEL "models/player/new_players_models.mdl"
;"some_old_weapon_model" "some_new_weapon_model"
;"some_old_sprite" "some_new_sprite"
;"some_old_sound" "some_new_sound"

;Change things on a specific team:
;TEAM( you can use CT / TERRORIST )
;PLAYER_MODEL = "models/player/new_player_from_the_team_models.mdl" //change all player models from that team
;"some_old_weapon_model" "some_new_weapon_model" 
;"some_old_sprite" "some_new_sprite"
;"some_old_sound" "some_new_sound"
;Anything changed here is for all the team

;The values are read as:
;If the current player has a custom config this will be taken into account, no matter other settings.
;If the current player doesn't has a custom config then check the team config, this will be taken into account, no matter the global config
;If no player & no team config the global config will be taken into account
;If no player & no team & no global config the resources will not be changed for that player

;I used the word "player" because this is for what most of you will use it, but it may change other ent resources
Code:
;READ THIS!!!!!!
;Your path size must be equalto the original one, or you will get errors.
;!!!!!!!!

;INSTRUCTIONS:

;Models:
;old_model new_model
;You must include model/ and .mdl

;Sounds:
;old_sound new_sound
;You must not include /sound but you should add .wav
;Only wav files, without mp3

;Sprites:
;old_sprite new_sprite
;You must include /sprites and .spr


;Ex:
;This will change all ak47 models to m4a1 ones. This models paths has the same size, so it's fine.
;models/v_ak47.mdl models/v_m4a1.mdl
;models/p_ak47.mdl models/p_m4a1.mdl
;models/w_ak47.mdl models/w_m4a1.mdl


;Ex:
;This will change the sound emited when you kit a wall with the knife
;You MUST use sound/ in the path!!!!!!
;For weapons, you can only change knife sound, but with this plugin you can replace every sound 
;that is handled server side.
;sound/weapons/knife_hitwall1.wav sound/weapons/ak7-1.wav

;Add your custom configs here:

models/v_ak47.mdl models/v_m4a1.mdl
models/p_ak47.mdl models/p_m4a1.mdl
models/w_ak47.mdl models/w_m4a1.mdl
Also, the update to 0.7 version will bring more changes about the code, but you will see then when I finish working on it. What I can say for now is than okapi is replaced by orpheu, since it was fixed.

Arkshine, do you think that this changes are enough for approval(if the code will be good too) ?
__________________

Last edited by HamletEagle; 11-16-2014 at 05:47.
HamletEagle is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 11-17-2014 , 13:30   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #43

Quote:
Originally Posted by HamletEagle View Post
Working on a huge update. This will allow you to have dynamic and static configuration. You will have two files that looks like this:

Code:
;This file allow you to dynamically change entites resources
;You can have resources changed for different players, for vips, for maps and so on.
;Here you have multiple types of posibilities

;Change things by SteamId:

;STEAMID
;OLD_RESOURCE NEW_RESOURCE
;You can make than a specific player to have custom skins, to have a custom model and so on.
;If you want to set up a player model please specify PLAYER_MODEL key in front of the model.

;Example:
;STEAM_blablablabla
;PLAYER_MODEL "models/player/new_player_model.mdl"
;"old_weapon_model" "new_weapon_model"

;Change things globally( like for all players ):
 
;PLAYER_MODEL "models/player/new_players_models.mdl"
;"some_old_weapon_model" "some_new_weapon_model"
;"some_old_sprite" "some_new_sprite"
;"some_old_sound" "some_new_sound"

;Change things on a specific team:
;TEAM( you can use CT / TERRORIST )
;PLAYER_MODEL = "models/player/new_player_from_the_team_models.mdl" //change all player models from that team
;"some_old_weapon_model" "some_new_weapon_model" 
;"some_old_sprite" "some_new_sprite"
;"some_old_sound" "some_new_sound"
;Anything changed here is for all the team

;The values are read as:
;If the current player has a custom config this will be taken into account, no matter other settings.
;If the current player doesn't has a custom config then check the team config, this will be taken into account, no matter the global config
;If no player & no team config the global config will be taken into account
;If no player & no team & no global config the resources will not be changed for that player

;I used the word "player" because this is for what most of you will use it, but it may change other ent resources
Code:
;READ THIS!!!!!!
;Your path size must be equalto the original one, or you will get errors.
;!!!!!!!!

;INSTRUCTIONS:

;Models:
;old_model new_model
;You must include model/ and .mdl

;Sounds:
;old_sound new_sound
;You must not include /sound but you should add .wav
;Only wav files, without mp3

;Sprites:
;old_sprite new_sprite
;You must include /sprites and .spr


;Ex:
;This will change all ak47 models to m4a1 ones. This models paths has the same size, so it's fine.
;models/v_ak47.mdl models/v_m4a1.mdl
;models/p_ak47.mdl models/p_m4a1.mdl
;models/w_ak47.mdl models/w_m4a1.mdl


;Ex:
;This will change the sound emited when you kit a wall with the knife
;You MUST use sound/ in the path!!!!!!
;For weapons, you can only change knife sound, but with this plugin you can replace every sound 
;that is handled server side.
;sound/weapons/knife_hitwall1.wav sound/weapons/ak7-1.wav

;Add your custom configs here:

models/v_ak47.mdl models/v_m4a1.mdl
models/p_ak47.mdl models/p_m4a1.mdl
models/w_ak47.mdl models/w_m4a1.mdl
Also, the update to 0.7 version will bring more changes about the code, but you will see then when I finish working on it. What I can say for now is than okapi is replaced by orpheu, since it was fixed.

Arkshine, do you think that this changes are enough for approval(if the code will be good too) ?
Waiting for the 0.7 version.
bLacK-bLooD is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 11-19-2014 , 17:59   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #44

My apologies for the double post.

Apparently there is a conflict between this plugin and Frostnades: https://forums.alliedmods.net/showthread.php?t=41126

I believe it is because it uses FM_SetModel. Is anything we can do about it so the frostnades plugin will run together with your plugin?
bLacK-bLooD is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-20-2014 , 05:48   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #45

The frostnade plugin can be edited with my api so it will be compatible.
__________________
HamletEagle is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 11-20-2014 , 06:19   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #46

I have included the inc in the plugin, targeted the new path with your example, but i have no idea what to edit in fw_setmodel.

PHP Code:
#include <err_api>

//

public plugin_init()
{
    
//

    
new szString128 ];
    
err_find_replaced_string("models/w_smokegrenade.mdl"szString);

    
//
}

// entity is given a model (used to detect for thrown grenades)
public fw_setmodel(ent,model[])
{
    if(!
get_pcvar_num(pcv_enabled)) return FMRES_IGNORED;

    new 
owner pev(ent,pev_owner);
    if(!
is_user_connected(owner)) return FMRES_IGNORED;
    
    
// this isn't going to explode
    
new Float:dmgtime;
    
pev(ent,pev_dmgtime,dmgtime);
    if(
dmgtime == 0.0) return FMRES_IGNORED;
    
    new 
typecsw;
    if(
model[7] == 'w' && model[8] == '_'//here i guess we get the index of 7, which is models/W, followed by index 8, which is _, so w_ 
    
{
        switch(
model[9])
        {
            case 
'h': { type NT_HEGRENADEcsw CSW_HEGRENADE; }
            case 
'f': { type NT_FLASHBANGcsw CSW_FLASHBANG; }
            case 
's': { type NT_SMOKEGRENADEcsw CSW_SMOKEGRENADE; }
        }
    }
    if(!
type) return FMRES_IGNORED;
    
    new 
team _:cs_get_user_team(owner);

    
// have a frostnade (override off) ;OR; override enabled, on valid team, using valid frostnade type
    
if(hasFrostNade[owner] == csw || (get_pcvar_num(pcv_override)
            && (
get_pcvar_num(pcv_teams) & team) && (get_pcvar_num(pcv_nadetypes) & type)))
    {
        
// not using override
        
if(hasFrostNade[owner] == csw)
        {
            
hasFrostNade[owner] = 0;
            if(
get_pcvar_num(pcv_icon) == ICON_HASNADE)
            {
                
show_icon(ownerSTATUS_HIDE);
            }
        }

        
set_pev(ent,pev_team,team);
        
set_pev(ent,pev_bInDuck,1); // flag it as a frostnade

        
new rgb[3], Float:rgbF[3];
        
get_rgb_colors(team,rgb);
        
IVecFVec(rgbrgbF);
        
        
// glowshell
        
set_pev(ent,pev_rendermode,kRenderNormal);
        
set_pev(ent,pev_renderfx,kRenderFxGlowShell);
        
set_pev(ent,pev_rendercolor,rgbF);
        
set_pev(ent,pev_renderamt,16.0);

        
set_beamfollow(ent,10,10,rgb,100);
    }

    return 
FMRES_IGNORED;

I explained as much as I could in the plugin. I thought that by increasing the index number i would target my new destination (models/x/w_sball.mdl), but i don't know if the indexes work with new folders.

Last edited by bLacK-bLooD; 11-20-2014 at 06:20.
bLacK-bLooD is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-21-2014 , 10:20   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #47

Code:
new g_szNewModel[ 128 ] plugin_init() {     err_find_replaced_string("models/w_smokegrenade.mdl", g_szNewModel) } FM_SetModel Hook: if(equal(model, g_szNewModel)) {     //do your stuffs }

Forget the last post about the configuration file( dynamic one ). I found a better way and much more organised. Working on it
__________________

Last edited by HamletEagle; 11-21-2014 at 12:19.
HamletEagle is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 11-21-2014 , 17:41   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #48

I was wondering about your configuration file, you mentioned player specific replacements. How? For example, if you patch memory with new values, original memory is gone, so other players won't have default value. If you don't that, than there is no point of this plugin, cause you have to precache extra files for specific player, which will increase precache count and those replacements could be done with basic forwards/natives without Okapi.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-22-2014 , 05:54   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #49

Quote:
Originally Posted by GuskiS View Post
I was wondering about your configuration file, you mentioned player specific replacements. How? For example, if you patch memory with new values, original memory is gone, so other players won't have default value. If you don't that, than there is no point of this plugin, cause you have to precache extra files for specific player, which will increase precache count and those replacements could be done with basic forwards/natives without Okapi.
Hehe, you missed my point and also Arkshine's one. You will have two different ways of replacing, one that is permanent and that patch the string directly in memory and another one that hook DefaultDeploy and some other forwards to have configuration specific to players, teams and so on.
So, you can choose. And because it will bring more than every plugin posted here that has the same target it won't be useless.
__________________
HamletEagle is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 11-22-2014 , 09:28   Re: Entity Resources Replacement[ OKAPI ]
Reply With Quote #50

PHP Code:
public fw_setmodel(ent,model[])
{
    if(
equal(modelg_szNewModel)) 
    {
        if(!
get_pcvar_num(pcv_enabled)) return FMRES_IGNORED;

        new 
owner pev(ent,pev_owner);
        if(!
is_user_connected(owner)) return FMRES_IGNORED;
        
        
// this isn't going to explode
        
new Float:dmgtime;
        
pev(ent,pev_dmgtime,dmgtime);
        if(
dmgtime == 0.0) return FMRES_IGNORED;
        
        new 
typecsw;
        if(
model[7] == 'w' && model[8] == '_')
        {
            switch(
model[9])
            {
                case 
'h': { type NT_HEGRENADEcsw CSW_HEGRENADE; }
                case 
'f': { type NT_FLASHBANGcsw CSW_FLASHBANG; }
                case 
's': { type NT_SMOKEGRENADEcsw CSW_SMOKEGRENADE; }
            }
        }
        if(!
type) return FMRES_IGNORED;
        
        new 
team _:cs_get_user_team(owner);

        
// have a frostnade (override off) ;OR; override enabled, on valid team, using valid frostnade type
        
if(hasFrostNade[owner] == csw || (get_pcvar_num(pcv_override)
                && (
get_pcvar_num(pcv_teams) & team) && (get_pcvar_num(pcv_nadetypes) & type)))
        {
            
// not using override
            
if(hasFrostNade[owner] == csw)
            {
                
hasFrostNade[owner] = 0;
                if(
get_pcvar_num(pcv_icon) == ICON_HASNADE)
                {
                    
show_icon(ownerSTATUS_HIDE);
                }
            }

            
set_pev(ent,pev_team,team);
            
set_pev(ent,pev_bInDuck,1); // flag it as a frostnade

            
new rgb[3], Float:rgbF[3];
            
get_rgb_colors(team,rgb);
            
IVecFVec(rgbrgbF);
            
            
// glowshell
            
set_pev(ent,pev_rendermode,kRenderNormal);
            
set_pev(ent,pev_renderfx,kRenderFxGlowShell);
            
set_pev(ent,pev_rendercolor,rgbF);
            
set_pev(ent,pev_renderamt,16.0);

            
set_beamfollow(ent,10,10,rgb,100);
        }

        return 
FMRES_IGNORED;
    }

Somehow this doesn't work. I might do some stupid mistakes, but it doesn't make sense to me to wrap everything in that if and inside the if to have other checks for the models and grenade type. What am I doing wrong?
bLacK-bLooD is offline
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 16:08.


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