Author Topic: getItemCount, getSellCost, etc  (Read 4671 times)

0 Members and 1 Guest are viewing this topic.

KoRo

  • Fat, Emo Robot
  • Centurian Lord
  • ********
  • Posts: 3,436
  • Reputation: +14/-6
getItemCount, getSellCost, etc
« on: December 19, 2013 05:09 pm CST »
I'm familiar with some of the base Tribes functions for retrieving information about items in your inventory, but is there a function to retrieve the count for items in your storage? If not, is it possible to make one?

rjm003

  • Gnoll Fighter
  • **
  • Posts: 85
  • Reputation: +1/-2
Re: getItemCount, getSellCost, etc
« Reply #1 on: December 21, 2013 12:24 pm CST »
Yeah it wouldn't be hard to make one, but it would have to be done on the server end with a custom remote.

KoRo

  • Fat, Emo Robot
  • Centurian Lord
  • ********
  • Posts: 3,436
  • Reputation: +14/-6
Re: getItemCount, getSellCost, etc
« Reply #2 on: December 21, 2013 04:44 pm CST »
I'm not familiar with that term. What is a "custom remote"?

rjm003

  • Gnoll Fighter
  • **
  • Posts: 85
  • Reputation: +1/-2
Re: getItemCount, getSellCost, etc
« Reply #3 on: December 21, 2013 09:38 pm CST »
Its just another way for the server to communicate to the client. As an example here is a remote call that triggers on the client side (found in client.cs)

Code: [Select]
function nextWeapon()
{
// Up to the server right now
remoteEval(2048,nextWeapon);
}


And then the server code that handles the call to the remote (found in base item.cs):
Code: [Select]
function remoteNextWeapon(%client)
{
%item = Player::getMountedItem(%client,$WeaponSlot);
if (%item == -1 || $NextWeapon[%item] == "")
selectValidWeapon(%client);
else {
for (%weapon = $NextWeapon[%item]; %weapon != %item;
%weapon = $NextWeapon[%weapon]) {
if (isSelectableWeapon(%client,%weapon)) {
Player::useItem(%client,%weapon);
// Make sure it mounted (laser may not), or at least
// next in line to be mounted.
if (Player::getMountedItem(%client,$WeaponSlot) == %weapon ||
Player::getNextMountedItem(%client,$WeaponSlot) == %weapon)
break;
}
}
}
}

So you make the call to a function on the client and the server handles that call. Can be done in reverse order also. Tribes comes built with automatic detection on remote functions , simply by adding the word "remote" to the front of the function name. (A couple other functions work like that too, menu functions is one I can think of off the top of my head).

Anyways the point being all your storage data is saved as a string, So basically particle would need to make a remote on his side that you can call from the client to receive that string.

KoRo

  • Fat, Emo Robot
  • Centurian Lord
  • ********
  • Posts: 3,436
  • Reputation: +14/-6
Re: getItemCount, getSellCost, etc
« Reply #4 on: December 21, 2013 10:35 pm CST »
Interesting. I wasn't sure if equipment and storage info was client side or server side...I guess it makes sense that it would be server side so no one could go into their character file and just edit what they have. But on that note, what's the difference between the useItem("..."); function and the remoteEval(2048,useItem,#); function?

rjm003

  • Gnoll Fighter
  • **
  • Posts: 85
  • Reputation: +1/-2
Re: getItemCount, getSellCost, etc
« Reply #5 on: December 21, 2013 11:06 pm CST »
Useitem is just making the call to the remoteUseItem, why they did it this way i'm not sure. Its an extra step heh.