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-25-2005, 07:52 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
onActionServerside

NPC Code:

function onActionServerside(command, arg) {
switch(params[0]) {
case "stats":
// player.chat = "boo";
switch (params[1]) {
case "hurt":
dmg = params[2];
hp = clientr.health[0];
clientr.health[0] = hp - dmg;
break;
}
break;
}
}



The script only works when the player.chat command is uncommented.

Anyway to fix this / is their a different way for triggeractions in GS2?
Reply With Quote
  #2  
Old 06-25-2005, 09:28 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Firstly, I'm not sure if you can use a switch immediately after a case.
Second, you've given the function two argument variables; why are you using params?
__________________
Skyld
Reply With Quote
  #3  
Old 06-25-2005, 09:29 PM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
Ew @ double switch case.
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #4  
Old 06-25-2005, 09:35 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
*Points the finger at Loriel*

So, how is this fixable?
Reply With Quote
  #5  
Old 06-25-2005, 09:50 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
seems to not like going right from a case to another switch... a bug is my guess
Reply With Quote
  #6  
Old 06-25-2005, 09:58 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Then is their anyway I can do it as how I am trying to?

I am trying to make it do like this:

if (strequals(#p(0),stats)) {
if (strequals(#p(1),hurt)) // Hurt
}

How would I do something like that in gscript2 then?
Reply With Quote
  #7  
Old 06-26-2005, 12:30 AM
Fry Fry is offline
Registered User
Fry's Avatar
Join Date: Sep 2001
Location: Germany
Posts: 384
Fry has a spectacular aura about
if (foo == bar)
foo and bar are variables. to see whether foo equals "test" (the string), do
if (foo == "test")
like you'd compare integers in GS1, just put quotes around strings.
__________________
Graal Statistics

Top 3 servers at the moment (players):


Reply With Quote
  #8  
Old 06-26-2005, 12:38 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally Posted by KuJi
Then is their anyway I can do it as how I am trying to?

I am trying to make it do like this:

if (strequals(#p(0),stats)) {
if (strequals(#p(1),hurt)) // Hurt
}

How would I do something like that in gscript2 then?
NPC Code:

function onActionServerside() {
if (params[1] == "stats") {
if (params[2] == "hurt") {
//stuff
} else if (params[2] == "stuff") {
}
} else if (params[1] == "stuff") {
}
}

Reply With Quote
  #9  
Old 06-26-2005, 12:45 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Hmm, that would work..but what is switch for then?
Reply With Quote
  #10  
Old 06-26-2005, 01:04 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally Posted by KuJi
Hmm, that would work..but what is switch for then?
not like switch is a graal-unique thing.. other langs have it, its purpose is to make things like more organized, also you can do something like

NPC Code:

case 1:
case 2:
case 3:
player.chat = "foo";
break;


while the elseif form of that would be much longer
Reply With Quote
  #11  
Old 06-26-2005, 03:13 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
So it is some sort of replacement of else?

EX:
if (playerchats) {
if (strequals(#c,boo)) setplayerprop#c,boo; else
if (strequals(#c,bam)) setplayerprop#c,bam; else
if (strequals(#c,woo)) setplayerprop#c,woo;
}
Reply With Quote
  #12  
Old 06-26-2005, 05:23 AM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
Quote:
Originally Posted by KuJi
So it is some sort of replacement of else?

EX:
if (playerchats) {
if (strequals(#c,boo)) setplayerprop#c,boo; else
if (strequals(#c,bam)) setplayerprop#c,bam; else
if (strequals(#c,woo)) setplayerprop#c,woo;
}
yes
__________________

Reply With Quote
  #13  
Old 06-26-2005, 09:35 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally Posted by KuJi
So it is some sort of replacement of else?

EX:
if (playerchats) {
if (strequals(#c,boo)) setplayerprop#c,boo; else
if (strequals(#c,bam)) setplayerprop#c,bam; else
if (strequals(#c,woo)) setplayerprop#c,woo;
}
This is why you learn how to code and not just memorize how things work...
Reply With Quote
  #14  
Old 06-26-2005, 05:10 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Err O.o?
Reply With Quote
  #15  
Old 06-28-2005, 03:19 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
Quote:
Originally Posted by KuJi
So it is some sort of replacement of else?

EX:
if (playerchats) {
if (strequals(#c,boo)) setplayerprop#c,boo; else
if (strequals(#c,bam)) setplayerprop#c,bam; else
if (strequals(#c,woo)) setplayerprop#c,woo;
}
Like so =D

PHP Code:
#//CLIENTSIDE
function onPlayerchats(){
  
test player.chat;
  switch (
test) {
    case 
"boo":
      
player.chat "Test 1";
      break;
    case 
"bam":
      
player.chat "Test 2";
      break;
    case 
"woo":
      
player.chat "Test 3";
      break;
  }

hope it helps
__________________

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 10:28 AM.


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