Thread: Weapon
View Single Post
  #5  
Old 05-09-2011, 09:54 PM
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
Quote:
Originally Posted by mrnothersan View Post
Right... so my NPC script currently looks like this:
PHP Code:
function onActionPlayerOnline() { 
  
player.addWeapon("testgui","Tailor"); 

(from a previous script and i just add
PHP Code:
,"Tailor" 
... will it still work if i remove
PHP Code:
player
?


EDIT: I removed player. and applied... entered game and it 1.Removed all my tools. 2.Didn't give me testgui or Tailor....
Don't remove the prefix. The code Jer posted was perfect:

Quote:
Originally Posted by fowlplay4 View Post
PHP Code:
function onActionPlayerOnline() {
  
// Array of weapons to add to the player.
  
temp.weps = {
    
"-System""OtherWeapon""Example"
  
};
  
// Loops through each weapon in the array and adds it to the player.
  
for (temp.weptemp.weps) {
    
player.addweapon(temp.wep);
  }

TServerPlayer.addWeapon(str) only accepts one parameter (the weapon name). To add multiple weapons, you have to call it multiple times.

PHP Code:
function onActionPlayerOnline() {
  
player.addWeapon("-System");
  
player.addWeapon("-Tailor");
  
// etc

Jer's example (which I quoted above) does the same thing in a much nicer way using loops and arrays.
__________________
Reply With Quote