Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-20-2006, 08:49 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
ActionServerside() and player functions

Alright.
If I trigger onActionServerside() and call a player-function in the block, my params[] array will be overwritten by the player-function.

PHP Code:
//NPC Weapon
function onActionServerside() {
  echo(
"params[0] before call:" SPC params[0]);
  
player.DoStuff("abc","123","doremi");
  echo(
"params[0] after call:" SPC params[0]);
}

//#CLIENTSIDE
function onPlayerChats() {
  
triggerserver("gui",name,player.chat);

The first echo will give me player.chat
The second echo will give me 'abc'

Shouldn't the params[] for the weapon be inside the weapon object?
Reply With Quote
  #2  
Old 07-20-2006, 09:43 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
The params[] array is a global variable which always contains the parameters passed to a script call, either from outside (like onActionServerside) or by calling the function of another object. The params[] variable is not containing the parameters passed to the function. That's why you need to save it to a temporary variable if you want to use it later.

If the onActionServerSide function always expects the same number of parameters, you can also name the parameters in the function-declaration, then you don't need to copy them to temporary variables yourself. Something like this:
PHP Code:
function onActionServerside(chat) {
  echo(
"player chat: " chat);

Reply With Quote
  #3  
Old 07-21-2006, 07:01 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
uhh.. you know in the latest update of the NPC server a bug was added with the params array. Caused only a little bit of damage trouble on classic.

If you triggeraction serverside, params.size() will return 1, even if it's intended to be 0. The value is set to null.
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 12:18 PM.


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