Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   is player.equip(float) the same as setstring clientr.equipped_id,#v(float); ? (https://forums.graalonline.com/forums/showthread.php?t=84253)

Tyhm 02-16-2009 11:56 PM

is player.equip(float) the same as setstring clientr.equipped_id,#v(float); ?
 
Yeah, I don't get MUD functions at all, and asking the wiki just gives me a bunch of old advertisements for Kingdoms. (THANKS! -_-)

Basically, that system NPC I inherited does
PHP Code:

if (clientr.equipped_id != NULLunequipItem(temp.pl);
  
  
temp.item temp.pl.getItem(temp.id);
  
  if (
temp.item[3] == "ammo") {
    return;
  }
  
  
temp.pl.equip(temp.id);
  
  
temp.pl.triggerclient("gui"this.name"equip"); 

Then seems to expect the equip command to cause

PHP Code:

clientr.equipped[3] == "gun"
setshootparams(clientr.equipped[5]); 

etc; it's easy enough to
PHP Code:

    temp.tyid=clientr.equipped_id 0;
    
temp.tokens clientr.(@"item_"@tyid).tokenize(); 

instead, but I don't understand player.equip(float) enough to trust a workaround - should I just be saying, right after player.equip, to tokenize and assign
PHP Code:

clientr.equipped[5]=temp.tokens[5

? (or even tidier),perhaps
PHP Code:

clientr.equipped=clientr.(@"item_"@tyid).tokenize(); 

?)

cbk1994 02-17-2009 12:03 AM

The wiki doesn't neccesarily advertise Kingdoms functions. They are built directly into the NPC-Server (hard-coded; it makes it rather hard for Kingdoms staff to change them because Stefan is the only one who can, and then he has to update the NPC-Server).

"player.equip()" is not a built-in function. Can you please post the code for that function?

It's usually best to use player functions whenever possible, by the way. That way, if you ever need to change something, it's easy to. Plus you can make sure that all code is done correctly.

Tyhm 02-17-2009 12:22 AM

That's just it - player.equip() doesn't seem to exist Anywhere. It goes "An NPC calls
PHP Code:

      temp.pl findplayerbycommunityname(params[1]);
      
PlayerSystem.equip(temp.plparams[2]); 

;
playersystem has
PHP Code:

public function equipItem(temp.pltemp.id) {
  if (
clientr.equipped_id != NULLunequipItem(temp.pl);
  
  
temp.item temp.pl.getItem(temp.id);
  
  if (
temp.item[3] == "ammo") {
    return;
  }
  
  
temp.pl.equip(temp.id);
  
  
temp.pl.triggerclient("gui"this.name"equip");


and all it seems to do is set clientr.equipped_id - but that might be the Custom Inventory doing that, and maybe player.equip() does nothing at all. I'm trying to talk the server in question's owner into ditching the whole half-baked mess in favor of something I understand, but 1) that's how Classic stagnated, 2) he's never frelling ON, and 3) he's apparently still in a swoon over the concept of having Custom Everything.

Me, I just wanna shoot me some zombies.

cbk1994 02-17-2009 12:29 AM

I would create a class with an equip function in it, join it to the player, and simply have it call the player system weapon where that function is located; it looks like that is what it's meant to do anyway.

Tyhm 02-17-2009 12:37 AM

Huh. You can join a class to a player? I wonder if that's what's happening...what does that look like?

Narf, right you are brain, there it is, thanks. :-D

Still, I have no idea where it's Joined; there's a class player_functions that has equip(float), and it calls item_fonctions(sic)'s getItem(float) - which doesn't get called, because somewhere it's disjointed...

Am I just looking for somewhere up the tree, join player_functions; join item_functions; ?

No, apparently item_functions is just Joined automatically somewhere...-_-

At least fixing the name typo fixed a lot of the problems...

cbk1994 02-17-2009 02:54 AM

Try player.join("player_functions") when the player logs on (from serverside).

Tyhm 02-17-2009 02:59 AM

It must be hiding in one of these weapons...ah well, it's fixed now anyway. :-D

xXziroXx 02-17-2009 04:59 PM

Quote:

Originally Posted by Tyhm (Post 1467153)
It must be hiding in one of these weapons...ah well, it's fixed now anyway. :-D

/scriptscan all insertnameofclasshere



Also, the equip function etc. remind me an awful lot of the one I scripted and released in the code library.

Tyhm 02-17-2009 05:10 PM

It probably was. Codein made half a system NPC and quit, and the last I heard from Insomnia's manager he insisted I use it rather than throw it out and build something myself. :-P


All times are GMT +2. The time now is 07:31 PM.

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