Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Button Gui For Weapons (https://forums.graalonline.com/forums/showthread.php?t=134264395)

Gunderak 08-29-2011 06:20 AM

Button Gui For Weapons
 
basically i want to make a button that has player.weapon.name so whatever weapon you have selected if its on weapon fired activated it would be equipable to the button gui then then the button is pressed it finds the players current weapon and fires it.
lets take for example.
iv scripted an ak47 i could easily script the box to drop it into but how would i make the button actually do onweaponfired on the current weapon?
if anyone has any suggestions there much appriciated.
thanks.

Gunderak 08-29-2011 06:27 AM

PS: Im not asking for scripts/Script begging.
id just like to know the basics of what id have to do to accomplish this.

fowlplay4 08-29-2011 07:05 AM

You can trigger the player's currently selected weapon with:

player.weapon.trigger("WeaponFired", "");

Gunderak 08-29-2011 07:08 AM

wow, that was incredibly easy. i feel so dumb.
is there any way to check if the weapon the player is trying to set as a button has onWeaponFired(){ in it to see if its allowed to be equiped or not? thanks.
now i just need to script dragging of weapons to slots x_x
Quote:

You must spread some reputation around before giving it to fowlplay4 again
Also is it ok if i use your online npc maker?
iv tested around with it and its brilliant!

Edit: shouldnt it have to be player.weapon.name.trigger?

fowlplay4 08-29-2011 07:21 AM

Quote:

Originally Posted by Gunderak (Post 1665968)
wow, that was incredibly easy. i feel so dumb.
is there any way to check if the weapon the player is trying to set as a button has onWeaponFired(){ in it to see if its allowed to be equiped or not? thanks.
now i just need to script dragging of weapons to slots x_x

You should just set a flag in the weapon to check if it's a "weapon" on your server. I.e:

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.itemtype = "weapon";
} 

then you can use:

if (player.weapon.itemtype == "weapon") {

else where.

Quote:

Also is it ok if i use your online npc maker?
iv tested around with it and its brilliant!
It was made for others to use.

Quote:

Edit: shouldnt it have to be player.weapon.name.trigger?
No. player.weapon is the object currently selected weapon and player.weapon.name is just the weapon's name.

You can get weapon objects by using findweapon or referencing the object directly. I.e:

For -System

findweapon("-System") or (@"-System") both would refer to the -System weapon object. Direct referencing is more efficient but using findweapon is alright too.


All times are GMT +2. The time now is 10:56 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.