Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-21-2013, 08:56 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Removing Multiple Weapons

PHP Code:
removeWeapon("Test/One");
removeWeapon("Test/Two");
removeWeapon("Test/Three"); 
Is there a way to remove all weapons starting with Test/ ?
Reply With Quote
  #2  
Old 07-21-2013, 09:02 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
PHP Code:
for (temp.wplayer.weapons) {
  if (
temp.w.starts("Test/")) player.removeWeapon(temp.w);

__________________
MEEP!
Reply With Quote
  #3  
Old 07-21-2013, 09:02 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
PHP Code:
for ( temp.wplayer.weapons)
{

  if ( 
temp.w.starts("Test/"))
    
player.removeWeapontemp.w);


Edit: beat me to it Callimuc
__________________
Deep into the Darkness peering...
Reply With Quote
  #4  
Old 07-22-2013, 12:34 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Awesome. BUT what if I wanted to remove all weapons starting with Test/ except for Test/One for example? I tried this but it didn't work..

PHP Code:
for (temp.wplayer.weapons) {
  if (
temp.w.starts("Test/")) player.removeWeapon(temp.w);

sleep(0.05);
addWeapon("Test/One"); 
Reply With Quote
  #5  
Old 07-22-2013, 12:48 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
1st: you wouldnt even need the sleep
2nd: check if the weapon is not Test/One..

PHP Code:
temp.except = {"Test/One"}; //array of weapons starting with 'Test/' which should not be removed
for (temp.wplayer.weapons) {
  if (
temp.w.starts("Test/") && !(temp.w in temp.except)) player.removeWeapon(temp.w)

__________________
MEEP!
Reply With Quote
  #6  
Old 07-22-2013, 06:53 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
temp.w is a weapon, not a string! Stop abusing your objects!

PHP Code:
temp.w.name.starts("Test/"
PHP Code:
temp.w.name in temp.except 
PHP Code:
player.removeWeapon(temp.w.name
Also, the minimum sleep value on serverside is 0.1, not 0.05, and you lose the player scope when you sleep, so player.addWeapon isn't going to work anyway.
__________________
Reply With Quote
  #7  
Old 07-22-2013, 12:39 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
temp.w is a weapon, not a string! Stop abusing your objects!

PHP Code:
temp.w.name.starts("Test/"
PHP Code:
temp.w.name in temp.except 
PHP Code:
player.removeWeapon(temp.w.name
Also, the minimum sleep value on serverside is 0.1, not 0.05, and you lose the player scope when you sleep, so player.addWeapon isn't going to work anyway.
Aww, I must spread rep before showing you some love. Great advice.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:35 PM.


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