Scripts / [SOLVED] Destroying an entity with a specific weapon.

Author
Message
LucaRules
GameGuru TGC Backer
6
Years of Service
User Offline
Joined: 12th Feb 2015
Location: Verona (Italia)
Posted: 8th Oct 2020 13:47
Hi everyone, I need help with a script.
I would like to destroy an object with a precise weapon, for example with an axe I can destroy wooden crates, while with a pickaxe I can destroy a rock.

If I'm holding an axe I can't break the rock and if I'm holding a pickaxe I can't destroy wooden crates.

I used the attached script but both weapons destroy the object anyway and I don't know how to do it.
Windows 10 64-bit, Intel Core i7-6700K, GTX 980TI Zotac AMP Extreme, 16 GB RAM

The author of this post has marked a post as an answer.

Go to answer

Attachments

Login to view attachments
smallg
Community Leader
16
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Oct 2020 14:08
you can check which weapon the player is holding and if it's correct make the entity lose health and if it's not then restore the health lost
i.e.

just make sure the item won't be destroyed in 1 hit (i.e. has a decent amount of health to start with)
you can check the weapon "names" via Prompt(g_PlayerGunName) when the player is holding the weapon
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
LucaRules
GameGuru TGC Backer
6
Years of Service
User Offline
Joined: 12th Feb 2015
Location: Verona (Italia)
Posted: 8th Oct 2020 14:27
Hi Smallg thanks for your help I tried the script but I get this error, what could it be?

Windows 10 64-bit, Intel Core i7-6700K, GTX 980TI Zotac AMP Extreme, 16 GB RAM
smallg
Community Leader
16
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Oct 2020 17:18
This post has been marked by the post author as the answer.

ah yes, missed the other = sign in the if statement
p.s. remember if you rename the script you also need to rename the functions too
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
LucaRules
GameGuru TGC Backer
6
Years of Service
User Offline
Joined: 12th Feb 2015
Location: Verona (Italia)
Posted: 8th Oct 2020 17:58
Is perfect thanks again smallg.
Windows 10 64-bit, Intel Core i7-6700K, GTX 980TI Zotac AMP Extreme, 16 GB RAM

Login to post a reply

Server time is: 2022-01-28 05:51:52
Your offset time is: 2022-01-28 05:51:52