AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with capturing a new weapon (https://forums.alliedmods.net/showthread.php?t=12539)

Zor 04-17-2005 16:45

Help with capturing a new weapon
 
Ok...so here is the situation. I want to create a new weapon, its not really a weapon, but that irrelivent. Ok, so its smoke grenades. Now what I have been trying to do is the following:

I have a smoke grenade dor dod, I have already created it, so this is NOT the problem. What I want to do is the following:

1) Capture slot6 which is linked to a smake grenade icon, same as the grenades for slot5

2) When slot6 is hit, it switches to the model arms that is holding a smoke grenade, I'm working on these models now.

3) When they fire with this smoke grenade it shoots it off.

Cheers!

XxAvalanchexX 04-17-2005 19:58

This is only theory, I have no idea if it will work:

Code:
#define NADE_FLOOD 1.7 // change to anim time of grenade throw new smokeNades[33]; // smoke grenade amount new usingSmokeNade[33]; // if a smoke grenade is out new canThrowNade[33];  // if a user can throw a smoke grenade public plugin_init() {    register_clcmd("slot6","cmd_slot6");    register_event("CurWeapon","event_curweapon","b"); } public event_curweapon(id) {    canThrowNade[id] = 1;    remove_task(id,0);    usingSmokeNade[id] = 0; } public cmd_slot6(id) {    if(smokeNades[id] > 0) {       usingSmokeNade[id] = 1;       entity_set_string(id,EV_SZ_viewmodel,"models/v_smokenade.mdl");       entity_set_string(id,EV_SZ_weaponmodel,"models/w_smokenade.mdl");    } } public client_PreThink(id) {    if(!is_user_alive(id) || usingSmokeNade[id] == 0) {       return PLUGIN_CONTINUE;    }    new button = get_user_button(id);    if(button & IN_ATTACK) {       entity_set_int(id,EV_INT_button,button & ~IN_ATTACK);       if(canThrowNade[id] > 0) {          canThrowNade[id] = 0;          smokeNades[id]--;          set_task(NADE_FLOOD,"throw_nade",id);       }    }    if(button & IN_ATTACK2) {       entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2);    } } public throw_nade(id) {    // make grenade here    canThrowNade[id] = 1;    if(smokeNades[id] == 0) {       // switch back to some other weapon somehow    } }

There's a base. Good luck.

Zor 04-18-2005 07:28

@XxAvalanchexX

Thanks, I have the code already done for smoke grenades. And I tried to catch the slot6. But I think I may have tried client command already. It may be a console command instead. I will give this a try tonight if I'm able. What I was thinking/hoping was to use:

register_event("CurWeapon","cur_weapon","be", "1=1", "2=44")

Where I make a weapon thats linked to 44, I think DoD has like 40 weapons and 4 extra slots. But I need to figure that part out. What you can do at the moment is just throw the grenade, and throw or shoot at the same time. Not a good way to go about it. So the second thing I tried was to catch the grenade events as above, then if they hit it the second time it throws that event again and I switch to the smoke...but it didn't look like it worked. I could be wrong about it as the models I was using may have been the same as the ones for grenades.

So all in all, I will check what you put down out.

Cheers!


All times are GMT -4. The time now is 09:49.

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