AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   I need help! (https://forums.alliedmods.net/showthread.php?t=337462)

CataFan21 04-23-2022 00:07

I need help!
 
Happy Easter AlliedModders! 0-0

I'm trying the plugin on 1 bot test server and not work!


Code:

#include <amxmodx>
#include <fakemeta_util>
#include <engine>
#include <hamsandwich>
#include <cstrike>
#pragma compress 1
new bool:Has[33], Trail, cvar_bullets
        #define weapon_goldak47 "weapon_ak47"
        #define modelGold_v "models/akgold/v_ak47.mdl"
        #define modelGold_p "models/akgold/p_ak47.mdl"
        #define modelGold_w "models/akgold/w_ak47.mdl"
        #define key 10606
public plugin_init()
{
        register_plugin("GoldAk47", "0.1.0", "SweetMilitary")
        register_forward(FM_SetModel, "fw_SetModel")
        RegisterHam(Ham_Spawn,"player","Spawn", 1)
        RegisterHam(Ham_Item_AddToPlayer, weapon_goldak47, "Ak47Add")
        RegisterHam(Ham_Item_Deploy, weapon_goldak47, "Deploy", 1)
        RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
        RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
        RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
        RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
        RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
        RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
        RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
        RegisterHam(Ham_TakeDamage, "player", "Damage")
        cvar_bullets = register_cvar("cvar_goldbullets", "1")
}
public plugin_precache()
{
        precache_model(modelGold_v)
        precache_model(modelGold_p)
        precache_model(modelGold_w)
        Trail = precache_model("sprites/goldak_spr/laserbeam.spr")
}
public fw_SetModel(entity, model[])
{
        if(!is_valid_ent(entity))
        return FMRES_IGNORED
        static szClassName[33]
        entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))               
        if(!equal(szClassName, "weaponbox"))
        return FMRES_IGNORED
        static id
        id = entity_get_edict(entity, EV_ENT_owner)
        if(equal(model, "models/w_ak47.mdl"))
        {
        static ID       
        ID = find_ent_by_owner(-1, weapon_goldak47, entity)
        if(!is_valid_ent(ID))
        return FMRES_IGNORED
        if(Has[id])
                {
        entity_set_int(ID, EV_INT_impulse, key)               
        Has[id] = false               
        entity_set_model(entity, modelGold_w)                       
        return FMRES_SUPERCEDE
                }
        return FMRES_IGNORED
        }
        return FMRES_IGNORED
}       
public Damage(Vic, inflictor, Att, Float:damage, damage_bits) if(is_user_alive(Att) && damage_bits & DMG_BULLET) SetHamParamFloat(4, damage + random_float(1.0, 6.0))
public fw_TraceAttack(iEnt, Attack, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
        if(!is_user_alive(Attack) || get_pcvar_num(cvar_bullets) == 0)
                return HAM_IGNORED
        static Float:VEC[3]
        get_tr2(ptr, TR_vecEndPos, VEC)
        if(get_user_weapon(Attack) == CSW_AK47 && Has[Attack] == true)
        {
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte (TE_BEAMENTPOINT)
        write_short(Attack | 0x1000)
        engfunc(EngFunc_WriteCoord, VEC[0])
        engfunc(EngFunc_WriteCoord, VEC[1])
        engfunc(EngFunc_WriteCoord, VEC[2])
        write_short(Trail)
        write_byte(1)
        write_byte(15)
        write_byte(1)
        write_byte(14)
        write_byte(0)
        write_byte(255)   
        write_byte(255)     
        write_byte(0)
        write_byte(255)
        write_byte(255)
        message_end() 
        }
        return HAM_IGNORED
}
public Deploy(Ent)
{
        static id; id = get_pdata_cbase(Ent, 41, 4)
        if(Has[id] == true)
        {
        set_pev(id, pev_viewmodel2, modelGold_v)
        set_pev(id, pev_weaponmodel2, modelGold_p)
        }
}
public Spawn(id)
{       
        new random; random = random_num(1,10)       
        if(cs_get_user_team(id) == CS_TEAM_T && random == 1) Has[id] = true       
        else Has[id] = false       
}
public Ak47Add(weapon, id)
{
        if(!is_valid_ent(weapon))
        return HAM_IGNORED
        if(entity_get_int(weapon, EV_INT_impulse) == key) Has[id] = true
        return HAM_IGNORED
}

I think need code for connect player no?

if ( !is_user_alive ( id ) )

logs error:
04/23/2022 - 06:25:03: Info (map "zm_ice_attack3") (file "addons/amxmodx/logs/error_20220423.log")
L 04/23/2022 - 06:25:03: [CSTRIKE] Invalid player 3 (not in-game)
L 04/23/2022 - 06:25:03: [AMXX] Displaying debug trace (plugin "Goldak.amxx", version "0.1.0")
L 04/23/2022 - 06:25:03: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 04/23/2022 - 06:25:03: [AMXX] [0] Goldak.sma::Spawn (line 106)

Craxor 04-23-2022 01:49

Re: I need help!
 
public spawn(id)
{
new random = random_num(1,10);
If ( is_user_alive(id) && random == 1 && cs_get_user_team == CS_TEAM_T )
.....
}

CataFan21 04-23-2022 02:38

Re: I need help!
 
// C:\Users\Hanibac Alexandru\Desktop\SMA-COMP\Goldak.sma(106) : error 076: syntax error in the expression, or invalid function call
// C:\Users\Hanibac Alexandru\Desktop\SMA-COMP\Goldak.sma(108) : error 029: invalid expression, assumed zero
// C:\Users\Hanibac Alexandru\Desktop\SMA-COMP\Goldak.sma(108 -- 109) : warning 215: expression has no effect
// C:\Users\Hanibac Alexandru\Desktop\SMA-COMP\Goldak.sma(109) : warning 217: loose indentation
// C:\Users\Hanibac Alexandru\Desktop\SMA-COMP\Goldak.sma(109) : error 029: invalid expression, assumed zero
// C:\Users\Hanibac Alexandru\Desktop\SMA-COMP\Goldak.sma(109) : error 017: undefined symbol "Ak47Add"
// C:\Users\Hanibac Alexandru\Desktop\SMA-COMP\Goldak.sma(109) : fatal error 107: too many error messages on one line

not work :|

Craxor 04-23-2022 03:31

Re: I need help!
 
Those are compilation error i suppose?

Please post the new code with the modifications you maded .

kww 04-23-2022 05:08

Re: I need help!
 
offtop: such errors xD
Code:

public Spawn(id)
{       
        new random; random = random_num(1,10)
        if(cs_get_user_team(id) == CS_TEAM_T && random == 1) Has[id] = true       
        else Has[id] = false       
}

offtop end.

random is a native (i didn't try to use native name as a variable name)

Quote:

Originally Posted by Craxor (Post 2777616)
Those are compilation error i suppose?

Please post the new code with the modifications you maded .

he added what you said.

Craxor 04-23-2022 05:16

Re: I need help!
 
Opps , right , change variable name random into iRandomNum or something like that .

kww 04-23-2022 05:35

Re: I need help!
 
Quote:

Originally Posted by Craxor (Post 2777626)
Opps , right , change variable name random into iRandomNum or something like that .

it was so strange but it successfully compiles with random as variable name xd

https://i.ibb.co/gTqL7nC/image.png

You made an error here:
Quote:

If ( is_user_alive(id) && random == 1 && cs_get_user_team(id) == CS_TEAM_T )
Also I don't think we need to check if user alive when he respawns (https://forums.alliedmods.net/showpo...87&postcount=5)

CataFan21 04-23-2022 14:00

Re: I need help!
 
Quote:

Originally Posted by kww (Post 2777628)
it was so strange but it successfully compiles with random as variable name xd

https://i.ibb.co/gTqL7nC/image.png

You made an error here:


Also I don't think we need to check if user alive when he respawns (https://forums.alliedmods.net/showpo...87&postcount=5)

Thx bro work i compilate 100% but i have a new error!

L 04/23/2022 - 20:56:23: [HAMSANDWICH] Function player_hurt not found.
L 04/23/2022 - 20:56:23: [AMXX] Displaying debug trace (plugin "Goldak.amxx", version "0.1.0")
L 04/23/2022 - 20:56:23: [AMXX] Run time error 10: native error (native "RegisterHam")
L 04/23/2022 - 20:56:23: [AMXX] [0] Goldak.sma::plugin_init (line 17)

kww 04-23-2022 15:05

Re: I need help!
 
Quote:

Originally Posted by CataFan21 (Post 2777685)
Thx bro work i compilate 100% but i have a new error!

L 04/23/2022 - 20:56:23: [HAMSANDWICH] Function player_hurt not found.
L 04/23/2022 - 20:56:23: [AMXX] Displaying debug trace (plugin "Goldak.amxx", version "0.1.0")
L 04/23/2022 - 20:56:23: [AMXX] Run time error 10: native error (native "RegisterHam")
L 04/23/2022 - 20:56:23: [AMXX] [0] Goldak.sma::plugin_init (line 17)

Post the code again. We need to see it

CataFan21 04-24-2022 04:00

Re: I need help!
 
Quote:

#include <amxmodx>
#include <fakemeta_util>
#include <engine>
#include <hamsandwich>
#include <cstrike>
#pragma compress 1
new bool:Has[33], Trail, cvar_bullets
#define weapon_goldak47 "weapon_ak47"
#define modelGold_v "models/akgold/v_ak47.mdl"
#define modelGold_p "models/akgold/p_ak47.mdl"
#define modelGold_w "models/akgold/w_ak47.mdl"
#define key 10606
public plugin_init()
{
register_plugin("GoldAk47", "0.1.0", "SweetMilitary")
register_forward(FM_SetModel, "fw_SetModel")
RegisterHam(Ham_TakeDamage, "player", "player_hurt")
RegisterHam(Ham_Item_AddToPlayer, weapon_goldak47, "Ak47Add")
RegisterHam(Ham_Item_Deploy, weapon_goldak47, "Deploy", 1)
RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
RegisterHam(Ham_TakeDamage, "player", "Damage")
cvar_bullets = register_cvar("cvar_goldbullets", "1")
}
public plugin_precache()
{
precache_model(modelGold_v)
precache_model(modelGold_p)
precache_model(modelGold_w)
Trail = precache_model("sprites/goldak_spr/laserbeam.spr")
}
public fw_SetModel(entity, model[])
{
if(!is_valid_ent(entity))
return FMRES_IGNORED
static szClassName[33]
entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
if(!equal(szClassName, "weaponbox"))
return FMRES_IGNORED
static id
id = entity_get_edict(entity, EV_ENT_owner)
if(equal(model, "models/w_ak47.mdl"))
{
static ID
ID = find_ent_by_owner(-1, weapon_goldak47, entity)
if(!is_valid_ent(ID))
return FMRES_IGNORED
if(Has[id])
{
entity_set_int(ID, EV_INT_impulse, key)
Has[id] = false
entity_set_model(entity, modelGold_w)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
return FMRES_IGNORED
}
public Damage(Vic, inflictor, Att, Float:damage, damage_bits) if(is_user_alive(Att) && damage_bits & DMG_BULLET) SetHamParamFloat(4, damage + random_float(1.0, 6.0))
public fw_TraceAttack(iEnt, Attack, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
if(!is_user_alive(Attack) || get_pcvar_num(cvar_bullets) == 0)
return HAM_IGNORED
static Float:VEC[3]
get_tr2(ptr, TR_vecEndPos, VEC)
if(get_user_weapon(Attack) == CSW_AK47 && Has[Attack] == true)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte (TE_BEAMENTPOINT)
write_short(Attack | 0x1000)
engfunc(EngFunc_WriteCoord, VEC[0])
engfunc(EngFunc_WriteCoord, VEC[1])
engfunc(EngFunc_WriteCoord, VEC[2])
write_short(Trail)
write_byte(1)
write_byte(15)
write_byte(1)
write_byte(14)
write_byte(0)
write_byte(255)
write_byte(255)
write_byte(0)
write_byte(255)
write_byte(255)
message_end()
}
return HAM_IGNORED
}
public Deploy(Ent)
{
static id; id = get_pdata_cbase(Ent, 41, 4)
if(Has[id] == true)
{
set_pev(id, pev_viewmodel2, modelGold_v)
set_pev(id, pev_weaponmodel2, modelGold_p)
}
}
public spawn(id)
{
new random = random_num(1,10)

if(cs_get_user_team(id) == CS_TEAM_T && random == 1 )
{
Has[id] = true
}
else
{
Has[id] = false
}

}
public Ak47Add(weapon, id)
{
if(!is_valid_ent(weapon))
return HAM_IGNORED
if(entity_get_int(weapon, EV_INT_impulse) == key) Has[id] = true
return HAM_IGNORED
}
hook.Add("PlayerHurt", "traitortest", function(victim, attacker)
if (inuse) and IsValid(attacker:GetActiveWeapon()) and attacker:GetActiveWeapon():GetClass() == "weapon_ttt_oneshot" then
if victim:GetRole() == ROLE_TRAITOR then
victim:TakeDamage(200, attacker, self)
elseif victim:GetRole() != ROLE_TRAITOR then
attacker:TakeDamage(200, attacker, self)
end
end
end)


All times are GMT -4. The time now is 21:19.

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