Guest Posted March 13, 2008 Share Posted March 13, 2008 Alright, so I'm trying to get a script that will (as a server function) retrieve a player's weapon by slot <--client function. so I have in my server script function consoleweapon ( player ) local slot2 = triggerClientEvent ( player, "doGetWeps", getRootElement(), 2 ) outputChatBox ( ""..slot2.."" ) end addCommandHandler ( "weapon", consoleweapon ) and in my client script function getweps ( slot ) getPlayerWeapon ( player, slot ) end addEvent ( "doGetWeps" ) addEventHandler ( "doGetWeps", getRootElement(), getweps ) I have specified the server one as server and client as client in my meta.xml When I execute "weapon" it returns: ERROR: ...servscrpt.lua:264 : attempt to concatenate local 'slot2' (a boolean value) I know this means it isn't getting a value from my triggerClientEvent ( player, "doGetWeps", getRootElement(), 2 ) how do I fix this? Link to comment
tma Posted March 13, 2008 Share Posted March 13, 2008 Alright, so I'm trying to get a script that will (as a server function) retrieve a player's weapon by slot <--client function. You want a server function to get data from the client ? It's just that what you've shown can all be done with a client command because looking at your code: 1. triggerClientEvent() doesn't return a value result, but a boolean for if the command executed (event sent) - hence your error. 2. addEvent() takes two parameters - you'll need the second for remote execution. 3. The value from getPlayerWeapon() isn't stored / sent anywhere. If you want the server to do "something" with what's in the weapon slot, just do a client command handler, make the query and trigger a server event with the result (so you need a server event handler). If you're just showing what's in the slot to the player, just make it all client-side with a command handler. Link to comment
Guest Posted March 13, 2008 Share Posted March 13, 2008 My friend and I are assembling our own scripting to save player states upon leaving the server to an xml, and reloading this info when you join. So far we have stuff like skin, location, rotation, vehicle, vehicle rotation etc. We want to add a server side weapon info collection command so when the player leaves, it can be included in our commands when players leave the server. The trouble came when I'm wanting to get info from a client-side command but bring it server-side, so I can write it to the server's xml player databases. I'll try fiddling around with setting it up as client side triggering a server-side event i guess Link to comment
tma Posted March 13, 2008 Share Posted March 13, 2008 Why don't you add an event handler in the client for when the local player quits, that queries his weapon slot data and sends it to the server to be saved (along with the rest of the info) ? (Assuming this last packet of info is sent - I haven't sent anything client->server on player quit) Edit: Yeah, you might have a problem with who timing there. If the server has dropped the player before that info is sent, it won't know who to save it for. Easy enough to get round, or do a completely different way. The server could just track what weapons the client has for example. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now