AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Editing weapon help please (https://forums.alliedmods.net/showthread.php?t=56947)

hlstriker 06-24-2007 22:25

Editing weapon help please
 
I am trying to edit an existing weapon to create a 'new' weapon. Such as removing the existing weapons properties, then assigning new ones to it.

I thought to start I should remove the existing weapons fire and sound. I read the tutorial here on how to do that...
http://forums.alliedmods.net/showthread.php?t=41265

Now I have a problem because I can't capture when the player is holding attack.

Is there a way to remove all the existing weapons properties while still being able to detect when attack is being used?

hlstriker 06-26-2007 13:13

Re: Editing weapon help please
 
Is anyone able to help me with this?

I would appreciate it very much, thanks.

mogel 06-26-2007 14:50

Re: Editing weapon help please
 
Hi,

i have the same problem ... current i use a very bad workaround for the problem ... but i need a better solution

http://forums.alliedmods.net/showthread.php?p=424755

i think with this plugin is it posible to block the shoot, following by a fakedamage for the player ... please let me know if the idea work, thanks

hand, mogel

stupok 06-26-2007 16:34

Re: Editing weapon help please
 
Post the code you're using to block the animation and sound.

I think if you use:

Code:

set_cd(cd_handle, CD_ID, 0)
then you might be able to see when a client is pressing the attack key. I'm not sure.

hlstriker 06-26-2007 18:45

Re: Editing weapon help please
 
Yeah that's what I'm using and I couldn't seem to figure it out. Here is the code...

PHP Code:

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_forward(FM_UpdateClientData"UpdateClientData_Post"1);
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id))
    {
        return 
PLUGIN_CONTINUE;
    }
    
    
// Remove the attack button from their button mask
    
entity_set_int(idEV_INT_buttonentity_get_int(idEV_INT_button) & ~IN_ATTACK);
    
    if(
pev(idpev_button) & IN_ATTACK)
    {
        
// Added this to check if it would spam test when I held attack down
        
client_print(0print_chat"test");
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
UpdateClientData_Post(idsendweaponscd_handle)
{
    if(!
is_user_alive(id))
    {
        return 
FMRES_IGNORED;
    }
    
    
set_cd(cd_handleCD_ID0);
    
    return 
FMRES_HANDLED;



stupok 06-26-2007 20:13

Re: Editing weapon help please
 
What if you remove the line with entity_set_int? I don't think you need to remove the button AND change CD_ID with set_cd().

hlstriker 06-26-2007 20:42

Re: Editing weapon help please
 
Once again you fixed my problem stupok69 :D

Thanks :)

hlstriker 06-26-2007 22:39

Re: Editing weapon help please
 
Quote:

Originally Posted by hlstriker (Post 495180)
Once again you fixed my problem stupok69 :D

Thanks :)

EDIT:
Well sort of. I just noticed the gun will fire, but doesn't play the sound or animations (that's why I didn't catch it at first).

Is there a way to block the damage and ammo drain somehow?

EDIT:
GAH!!! I clicked quote instead of edit, my bad.

stupok 06-27-2007 01:21

Re: Editing weapon help please
 
I took a look at GabenMod, here's something useful:

from gm_soldier.sma by Basic-Master

Code:
public hook_prethink(id) {     if (g_IsEnabled && gHasClass[id] && is_user_alive(id) && gCurWeapon[id] == CSW_FLASHBANG) {         pt_button = pev(id, pev_button)         if (pt_button&IN_ATTACK)             set_pev(id, pev_button, pt_button&~IN_ATTACK)         if (pev(id, pev_oldbuttons)&IN_ATTACK) {             set_animation(id, 0)             set_pev(id, pev_oldbuttons, pev(id, pev_oldbuttons)&~IN_ATTACK)         }         if (!gActionAllowed[id] || !gm_IsValidPlayer(id))             return FMRES_HANDLED                 if (pt_button&IN_ATTACK) {             pt_delay = ROCKET_DELAY             if (cs_get_user_bpammo(id, CSW_FLASHBANG) != 0) {                 if (gReloadStatus[id] == 0) {                     set_pev(id, pev_punchangle, Float:{ -5.0, 0.0, 0.0 })                     set_animation(id, 3)                     cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG)-1)                     emit_sound(id, CHAN_WEAPON, "weapons/rocketfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)                     /* The rocket */                     new rocket = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))                     set_pev(rocket, pev_classname, "gm_rocket")                     if (!gSkills[id][5])                         engfunc(EngFunc_SetModel, rocket, "models/rpgrocket.mdl")                     else {                         engfunc(EngFunc_SetModel, rocket, "models/chick.mdl")                         set_pev(rocket, pev_framerate, 25.0)                         set_pev(rocket, pev_frame, 0.0)                     }                     dllfunc(DLLFunc_Spawn, rocket)                     new Float:fVec[3]                     pev(id, pev_origin, fVec)                     fVec[2] = floatadd(fVec[2], 15.0)                     set_pev(rocket, pev_owner, id)                     engfunc(EngFunc_SetOrigin, rocket, fVec)                     pev(id, pev_v_angle, fVec)                     set_pev(rocket, pev_angles, fVec)                     engfunc(EngFunc_SetSize, rocket, ROCKET_MINS, ROCKET_MAXS)                     set_pev(rocket, pev_mins, ROCKET_MINS)                     set_pev(rocket, pev_maxs, ROCKET_MAXS)                     set_pev(rocket, pev_absmin, ROCKET_MINS)                     set_pev(rocket, pev_absmax, ROCKET_MAXS)                     set_pev(rocket, pev_solid, SOLID_BBOX)                     set_pev(rocket, pev_movetype, MOVETYPE_FLYMISSILE)                     set_pev(rocket, pev_health, 9999.0)                     set_pev(rocket, pev_takedamage, 2.0)                     set_task(0.1, "task_checkrocket", rocket+300)                     gm_VelocityByAim(id, 2000+get_ent_speed(id), fVec)                     set_pev(rocket, pev_velocity, fVec)                     emit_sound(rocket, CHAN_VOICE, "weapons/rocket1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_HIGH)                     g_IsRocket[rocket] = 1                     /* Some fx */                     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)                     write_byte(22)                     write_short(rocket)                     write_short(gSteam)                     write_byte(10)                     write_byte(4)                     write_byte(200)                     write_byte(50)                     write_byte(50)                     write_byte(255)                     message_end()                     /* Player values */                     if (cs_get_user_bpammo(id, CSW_FLASHBANG) != 0 && !gSkills[id][2]) {                         gReloadStatus[id] = 1                         set_task(ROCKET_DELAY, "task_reload", id+200)                         pt_delay = floatadd(ROCKET_DELAY, RELOAD_DELAY)                         set_task(pt_delay, "task_reloadend", id+100)                     }                 }             }             else {                 if (is_user_bot(id)) // they rather commit suicide before they run out of ammo but who cares ^^                     client_cmd(id, "slot1")                 else                     emit_sound(id, CHAN_WEAPON, "weapons/357_cock1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             }             gActionAllowed[id] = 0             set_task(pt_delay, "task_reset", id)             return FMRES_SUPERCEDE         }     }     return FMRES_IGNORED }

kmal2t 06-27-2007 03:51

Re: Editing weapon help please
 
Code:
public FM_CStart(id, uc_handle, seed, cd_handle) {     if((get_uc(uc_handle,UC_Buttons) & IN_ATTACK) ) {         //shit         set_uc(uc_handle,UC_Buttons, get_uc(uc_handle,UC_Buttons) & ~IN_ATTACK);     } }

or the same concept with pev and set_pev with prethink


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

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