![]() |
Triggeraction on classes
I need help on a script I'm making. I'm trying to destroy a npc by trigger the server to destroy the npc, but it's not working for me I searched for triggeractions but I think mines set up correctly. its from a weapons script that places a class npc, im trying to get it to delete itself, on clientside it only deletes until you walk in the level again.
this is the class script NPC Code:function onActionTrigger() { |
PHP Code:
|
I'm trying to get my weapons script to work, I tried searching how to make a rate of fire, but it doesn't work while walking it only works when im standing still to shoot.
NPC Code: holding d on this makes me shoot when I change my direction i'm trying to make it shoot when im walking, it shoots when I move but only when I move |
Quote:
2nd: you should always do '==' checks and not '=' checks within if() statements and such now that we fixed this, your code will look like the following which makes it easier for us to read: PHP Code:
personally I would do something like: PHP Code:
I would still do one main script in a class and then have the weapons linked to that class using this.join("classname"); so once you are doing a change, you dont need to update all weapons (depending on the change) |
Quote:
Just a small addition to what callimuc posted, you do not need to check if something equals to true or false, as the if statement will go through if the value given equals true or false itself. For example NPC Code: is the same as doing NPC Code: the keydown() function returns a value of true or false depending on if the button specified is held down or not, and since booleans in graal basically converts into 1(true) and 0(false), we can use that! Also, doing if (1 == 1) is in theory slower than doing if (1) The speed difference isn't really noticed though, but here I am, saying it anyways :) Also another edition, the ! operator functions in the way that it inverses the bit. Basically 0 would become 1 and 0 would become 1. This is the reason you can do if (!keydown(4)) and it would fall through since the inverse of 0(false) is 1(true). |
Quote:
I basically set it to exactly what you posted calliumu but it doesn't shoot, reload or unequip. my old script works for everything except holding d , help me fix it by looking at my first post. It shoots fine it just doesn't work for holding shoot. Sorry but I don't want to completely have to reedit it I just need to add a sleep for the rate it fires, everything else works the way I made it orgionally unequip, shell and clip triggers, fire and the ganis work I see what your saying about how I made it, the automatic works, but its very unresponsive. I need the wording to make it if D is held. |
All times are GMT +2. The time now is 03:23 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.