Game Development Community

Simpleinventory system

by Camel Taylor · in Torque Game Engine · 10/12/2006 (12:46 am) · 3 replies

I have never thought about this before and never have read anything on the subject, but how do I get the players handle? Does a function that exist that simply , returns the client handle. I figured the best way of proably doing this is by going throught the %client some how, since the clilent points to player wich in turns points to myinventory. However I can't figure out how to grab a handle out of the air. I need to figure this out so that I can simpley press a button have the function grab the player's handle and use the item datablock to subtract the item and use it.

Thank you for any help

P.S. I know that I could make a global variable that just keeps a copy of the player handle at creation of the player object, I just wanted to know if there are any ingame scripts that handle this sort of situation. I'm really trying to do everything in game script

#1
10/12/2006 (11:37 am)
On the serverside, there is always a list of clients inside of the ClientGroup. It's a SimGroup, so you can search through it with the usual accesor methods for that. But if you're talking about a client modifying their inventory, that's something you should be doing on the server, so you probably should be sending that data with a commandToServer, which passes the client that send the command in as an argument. Just look at the starter.fps demo and see how it uses the health kit with a commandToServer bound to the 'h' key.
#2
10/12/2006 (12:02 pm)
Localclientconnection.player should work for single player. in script, the player object handle is just stored on the connection object when the player is first spawned. if you're making a multiplayer game and want to access some specific client who may or may not be running the server, youll have to use some logic to find it.
#3
10/15/2006 (1:01 am)
I don't know what i was thinking, or rather I did know. I keep thinking of things from a single player perspective, and ignoring the whole client server set up. I should have just used commandtoclient and commandtoserver which i did; after all I am making a two player project. Everything works fine now thanks for the reply