AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved unkown code error (https://forums.alliedmods.net/showthread.php?t=300501)

man_s_our 08-19-2017 09:18

unkown code error
 
I coded this after many compiling errors, but when Itried it it didn't work.
it was suposed to be used to change the skin to a random one from the list.
any help?
Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
new p_skin[33][32]
new const models[] = {
"player/gign/gign.mdl",
"player/gsg9/gsg9.mdl",
"player/sas/sas.mdl",
"player/spetsnaz/spetsnaz.mdl",
};
public plugin_init()
{
        register_plugin("imerge","1","man_s_our")
        register_concmd("imerge", "imerge",0)
        return PLUGIN_CONTINUE
}

public imerge(id)
{
        get_user_info(id,"model",p_skin[id],31);
        new mod = random(3);
        new model = models[mod];
        cs_set_user_model(id, models[mod])
        return PLUGIN_CONTINUE
}
public new_round(id)
{
        cs_set_user_model(id, p_skin[id])
}


DjSoftero 08-19-2017 09:32

Re: unkown code error
 
I think you need to check whether player is alive. function new_round() is not registered anywhere, so it cannot be called. You need to hook player spawn and then change it from there. all in all, it should look something like this:
Spoiler


as in model array:
PHP Code:

new const models[] = {
"player/gign/gign.mdl",
"player/gsg9/gsg9.mdl",
"player/sas/sas.mdl",
"player/spetsnaz/spetsnaz.mdl",
};
//this is incorrect, you need to write only a folder directory for a model.
//that is a case only for a player models tho 

this should be instead:
PHP Code:

new models[4][] = {
    
"player/gign",
"player/gsg9",
"player/sas",
"player/spetsnaz"



man_s_our 08-19-2017 12:35

Re: unkown code error
 
Quote:

Originally Posted by DjSoftero (Post 2542825)
I think you need to check whether player is alive. function new_round() is not registered anywhere, so it cannot be called. You need to hook player spawn and then change it from there. all in all, it should look something like this:
Spoiler


as in model array:
PHP Code:

new const models[] = {
"player/gign/gign.mdl",
"player/gsg9/gsg9.mdl",
"player/sas/sas.mdl",
"player/spetsnaz/spetsnaz.mdl",
};
//this is incorrect, you need to write only a folder directory for a model.
//that is a case only for a player models tho 

this should be instead:
PHP Code:

new models[4][] = {
    
"player/gign",
"player/gsg9",
"player/sas",
"player/spetsnaz"



thank you

man_s_our 08-20-2017 09:17

Re: unkown code error
 
unfortunately it didn't compile.
so I replaced the disguise with transparency.

Natsheh 08-20-2017 15:14

Re: unkown code error
 
Here you go...

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

new p_skin[33][32]

new const 
models[][] = {
"gign",
"gsg9",
"sas",
"spetsnaz"
}

public 
plugin_precache()
{
       new 
szText[64]

       for(new 
sizeof modelsi++) {
                  
formatex(szText63"models/player/%s/%s.mdl"models[i], models[i])
                  
precache_model(szText)
formatex(szText63"models/player/%s/%sT.mdl"models[i], models[i])
                  
precache_model(szText)
           }
}

public 
plugin_init()
{
    
register_plugin("imerge","1","man_s_our")
    
register_concmd("imerge""imerge",0)
        
RegisterHam(Ham_Spawn"player""fw_player_spawned"1)
        
RegisterHam(Ham_Respawn"player""fw_player_spawned"1)
}

public 
imerge(id)
{
        
formatex(p_skin[id], charsmax(p_skin[]),models[random(sizeof models)])
    
set_user_info(id,"model",p_skin[id])
    
cs_set_user_model(idp_skin[id])
}
public 
fw_player_spawned(id)

        if(!
is_user_alive(id)) return;
        
set_user_info(id,"model",p_skin[id])
    
cs_set_user_model(idp_skin[id])



kristi 08-20-2017 15:52

Re: unkown code error
 
Quote:

Originally Posted by Natsheh (Post 2543133)
Spoiler

http://amxmodx.org/api/ham_const
Code:
/**
     * Description:     Normally called when a map-based item respawns, such as a health kit or something.
     * Forward params:  function(this);      * Return type:     Entity.      * Execute params:  ExecuteHam(Ham_Respawn, this);      */     Ham_Respawn,

So it is probably not called for players.

man_s_our 08-20-2017 17:10

Re: unkown code error
 
thank you all for your help

Natsheh 08-20-2017 17:26

Re: unkown code error
 
Quote:

Originally Posted by kristi (Post 2543145)
http://amxmodx.org/api/ham_const
Code:
/**
     * Description:     Normally called when a map-based item respawns, such as a health kit or something.
     * Forward params:  function(this);      * Return type:     Entity.      * Execute params:  ExecuteHam(Ham_Respawn, this);      */     Ham_Respawn,

So it is probably not called for players.

why dont test?

DjSoftero 08-21-2017 01:41

Re: unkown code error
 
Quote:

Originally Posted by man_s_our (Post 2543054)
unfortunately it didn't compile.
so I replaced the disguise with transparency.

it didnt compile the code I gave you, or after you edited it? I`m asking because i always test my stuff and your compiler could be outdated.

man_s_our 08-21-2017 19:10

Re: unkown code error
 
Quote:

Originally Posted by DjSoftero (Post 2543237)
it didnt compile the code I gave you, or after you edited it? I`m asking because i always test my stuff and your compiler could be outdated.

that code itself


All times are GMT -4. The time now is 16:58.

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