View Full Version : ActionServerside() and player functions

07-20-2006, 08:49 PM
If I trigger onActionServerside() and call a player-function in the block, my params[] array will be overwritten by the player-function.

//NPC Weapon
function onActionServerside() {
echo("params[0] before call:" SPC params[0]);
echo("params[0] after call:" SPC params[0]);

function onPlayerChats() {

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?

07-20-2006, 09:43 PM
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:

function onActionServerside(chat) {
echo("player chat: " @ chat);

07-21-2006, 07:01 AM
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.