![]() |
Weapon Control
1 Attachment(s)
I keep getting very annoyed of adding the same line to add my weapons at the top of my scripts.
PHP Code:
The Script (-System/WepCtrl) PHP Code:
Thank you to everybody who helps me out. Styled using FowlPlay4's GS2 Beautifier |
Do you want this to be based on GUI controls? I find commands to be more handy. I got !addw and !rmvw to add/remove weapon NPCs on the fly. Works like a charm.
|
Quote:
Thanks! |
I would take the entire GUI Creation and move it into it's own function, versus having it in onCreated(), so that if you ever update the weapon, everyone who has it won't have it pop open on them!
Also, instead of using the two textEditCtrls, you could simply replace that with the text of your TextList, so you don't need to type in the name of the weapon, just select it from the list and hit add/remove. Lastly I would say to add braces in your top set of lines, for your : PHP Code:
It's really a personal preference, but I think it's easier to read/update in the future for others. Perhaps even come up with more unique/descriptive names for your ctrls so down the road you can just look at it and see what they correspond to! |
Quote:
Quote:
Quote:
|
I decided to take on board what crow said about how using the players chat is more efficient for adding weapons. I have decided to make a quick weapon adder using !add and !rem. Thank you crow <3
PHP Code:
Styled using FowlPlay4's GS2 Beautifier |
one of the first things you should do is verify who is actually sending this trigger to the server since it's incredibly insecure otherwise
and then while you're at it you should prefix addweapon and removeweapon with the proper object (player) |
Quote:
PHP Code:
|
A small comment on the "Chat vs. GUI" topic:
I think it's good to have both. Chat for "power players" (those who frequently), and GUI for new players or those who don't player often enough to bother remember commands. This is mainly the approach we take on Classic. But it become more critical to properly abstract things with this approach because otherwise you'll have duplicate code lying all over the place. |
Quote:
|
Quote:
But in the name of theory, if this was actually a public facing weapon, then I'd say have a weapon list, since just a text box isn't particularly friendly and is pretty much the exact same thing as a normal chat command. |
I think the best option would be to incorporate both within the same weapon. Allow players to be able to access the GUI if need-be to see a list of what they could add to themselves, or what they already have.
Then also allow for the chat commands for those who know what they have/need and can quickly add/remove things without having to navigate a GUI. |
in the onActionServerside portion of the script you should be verifying that the player who sent the trigger is actually someone you expect it to be, IE
if(player.account in serveroptions.staff.tokenize(",")) |
Ah okiedokie thanks for that.
|
Quote:
|
Quote:
|
Quote:
PHP Code:
|
Quote:
I guess you could do if( ((player.communityname.length() > 0) ? player.communityname : player.account) in severoptions.staff.tokenize(",")) to prevent incorrectly formatted staff lists that might have an empty value somewhere from returning true for players that haven't set their community name. |
Quote:
|
Quote:
Granted, I couldn't actually find any instances of an empty entry in the array but it was still returning true when I checked player.communityname in the array. each array member - PHP Code:
|
Quote:
|
Quote:
I didn't even think it would be problematic initially until all of a sudden I see RC get flooded with players warning each other. |
| All times are GMT +2. The time now is 10:55 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.