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

0 Members and 1 Guest are viewing this topic.

KoRo

  • Fat, Emo Robot
  • Centurian Lord
  • ********
  • Posts: 3,415
  • Reputation: +14/-6
getItemCount, getSellCost, etc
« on: December 19, 2013 11:09 PM GMT »
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 06:24 PM GMT »
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,415
  • Reputation: +14/-6
Re: getItemCount, getSellCost, etc
« Reply #2 on: December 21, 2013 10:44 PM GMT »
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 22, 2013 03:38 AM GMT »
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,415
  • Reputation: +14/-6
Re: getItemCount, getSellCost, etc
« Reply #4 on: December 22, 2013 04:35 AM GMT »
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 22, 2013 05:06 AM GMT »
Useitem is just making the call to the remoteUseItem, why they did it this way i'm not sure. Its an extra step heh.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
This question is designed to stop automated account registration.  Those accounts are typically used to post messages commonly referred to as _______.  (Same name as a meat product packed into a rectangular can):
A rectangle whose sides are all the same length is known most commonly as which shape?:
What color is the daytime sky?: