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 06-18-2013, 05:11 AM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
Removing weapons

Hey I'm just trying to make a weapon add and remove itself from my inventory, I can use addweapon(); and removeweapon() on levels but it doesn't work inside the weapons scripts. When I put them two commands in f2 it says its a unrecognized command. thank you and sorry for posting another noob topic

also im wondering how to drop a animation for a clip gani when the gun reloads so it stays on the ground

NPC Code:


//#CLIENTSIDE

function GraalControl.onKeyDown(code, key, scan) {
if (key == "t") {
freezeplayer(this.equip);
removeweapon("Weapon/BMP");
addweapon("Weapon/BMP2");
}


Last edited by defaultaccount; 06-18-2013 at 08:18 PM..
Reply With Quote
  #2  
Old 06-18-2013, 12:21 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Should be dogging that clientside and then do the adding and remodeling serverside.
Reply With Quote
  #3  
Old 06-18-2013, 06:50 PM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
I didn't post the whole script but it is clientside can you explain to me what you mean give me an example of how it should be because right now it just freezes my player and puts in f2 on scripts that it's an unrecognized command the removeweapon(); , but it works fine in the levels npcs

I tried adding it server side but it still didn't work

Last edited by defaultaccount; 06-18-2013 at 08:20 PM..
Reply With Quote
  #4  
Old 06-18-2013, 08:46 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
It's possible to remove weapons clientside (this.destroy() in the weapon—DO NOT DO THIS SERVERSIDE, IT WILL DELETE THE WEAPON FROM THE SERVER) but to add weapons you need to use player.addWeapon(weapon_name) and that must be done serverside. To remove weapons from a player serverside, use player.removeWeapon(weapon_name).
__________________
Reply With Quote
  #5  
Old 06-18-2013, 10:52 PM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
Quote:
Originally Posted by cbk1994 View Post
It's possible to remove weapons clientside (this.destroy() in the weapon—DO NOT DO THIS SERVERSIDE, IT WILL DELETE THE WEAPON FROM THE SERVER) but to add weapons you need to use player.addWeapon(weapon_name) and that must be done serverside. To remove weapons from a player serverside, use player.removeWeapon(weapon_name).
i'm trying to make it a key pressed but I don't know how to do that for serverside would it be

NPC Code:

function onKeyPressed(code, key) {
if (key == "t") {
player.addWeapon(weapon_name);
player.removeWeapon(weapon_name);




or how could I make it a function that the client side does and plays the serverside function

like this

NPC Code:

function onTierUp() {
player.addWeapon(weapon_name);
player.removeWeapon(weapon_name);

//#CLIENTSIDE

function onKeyPressed(code, key) {
if (key == "t") {
onTierUp():
}
}





I tried doing that before but it couldn't read the function
Reply With Quote
  #6  
Old 06-19-2013, 12:33 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
You need to use triggers to communicate between clientside and serverside. See these posts:
http://forums.graalonline.com/forums...84&postcount=6
http://forums.graalonline.com/forums...17&postcount=4
__________________
Reply With Quote
  #7  
Old 06-19-2013, 01:08 AM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
I read it but im still having trouble doing it

NPC Code:

function onActionServerSide() {
player.addWeapon(weapon/BMPTier1);
player.removeWeapon(weapon/BMP);
}
//#CLIENTSIDE
function GraalControl.onKeyDown(code, key, scan) {
if (key == "t") {
triggerServer("gui", weapon/bmp, null);



its all in the same script I put the action above my clientside and its still not working ingame
Reply With Quote
  #8  
Old 06-19-2013, 01:34 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
String literals (stuff like "weapon/bmp") should be in quotes.
__________________
Reply With Quote
  #9  
Old 06-19-2013, 01:48 AM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
is it proper otherwise? i'll try adding quotes I forgot to add them above ill add the quotes and see if that helps but other than that it should trigger the weapon change?

edit: I got it working, it added the gun but it didn't remove it ill test it out more later but it triggered the server side weapons change thank you cbk youre very helpful here on the forums

I cant get it to remove the weapon I have it set up like this

Quote:
function onActionServerSide() {
player.addWeapon("weapon/BMPTier1");
player.removeWeapon("weapon/BMP");
}
//#CLIENTSIDE
function GraalControl.onKeyDown(code, key, scan) {
if (key == "t") {
triggerServer("gui", this.name, null);
im going to try to do it with destroy clientside

I got it working with destroy(weapon/bmp); thanks cbk uve been very helpful

now i'm trying to make it so it can go down in level how would I be able to do that, I have it right now like it shows above but I want to make a trigger for a key to make it add the previous gun

NPC Code:
 
function onActionServerSide() {
player.addWeapon("Weapon/BMPTier3");
}
function onActionServerSide() {
player.addWeapon("Weapon/BMPTier1");
}
//#CLIENTSIDE
function GraalControl.onKeyDown(code, key, scan) {
if (key == "t") {
freezeplayer(this.equip);
triggerServer("gui", this.name, null);
destroy(Weapon/BMPTier2);
}
if (key == "g") {
freezeplayer(this.equip);
triggerServer("gui", this.name, null);
destroy(Weapon/BMPTier2);
}
}



basicly im wondering how to make it so it has two sever side triggers, I can currently can only make it have one serverside trigger I don't know how make it work...

Last edited by defaultaccount; 06-19-2013 at 03:49 AM..
Reply With Quote
  #10  
Old 06-19-2013, 05:04 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
When you post code, wrap it in [PHP] tags instead of [CODE] tags.

destroy() doesn't take any parameters, so you should just write this.destroy() instead of this.destroy(Weapon/BMPTier2);

Your first code looks fine; my guess is that your capitalization of the weapon name is off. I'm not certain but I'd guess player.removeWeapon might be case-sensitive. If it's not working, make sure you have the weapon name entered exactly as it should be (in some examples you use weapon/BMP and in others you use Weapon/BMP). You can also use this.name to refer to the current weapon name.

If you want to handle multiple possible actions serverside, send a parameter instead of null in your trigger. The parameter will be passed to the onActionServerSide event.

Something like this:

PHP Code:
function onActionServerSide(temp.cmd) {
  if (
temp.cmd == "levelUp") {
    
player.addWeapon("Weapon/BMPTier3");
    
player.removeWeapon(this.name);
  } else if (
temp.cmd == "levelDown") {
    
player.addWeapon("Weapon/BMPTier1");
    
player.removeWeapon(this.name);
  }
}

//#CLIENTSIDE
function GraalControl.onKeyDown(codekeyscan) {
  if (
key == "t") {
    
freezeplayer(this.equip);
    
triggerServer("gui"this.name"levelUp");
  } else if (
key == "g") {
    
freezeplayer(this.equip);
    
triggerServer("gui"this.name"levelDown");
  }

__________________
Reply With Quote
  #11  
Old 06-19-2013, 02:30 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by Cubical View Post
Should be dogging that clientside and then do the adding and remodeling serverside.
Auto correct for my phone was all over the place on that one.
Reply With Quote
  #12  
Old 06-19-2013, 07:09 PM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
Works perfectly now, thank you for the help. I managed to make an entire gunscript that works the way I need it to for my weapons.
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 08:38 AM.


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