coolman Posted December 24, 2011 Posted December 24, 2011 Resource 1#. i trigger localplayer from client to server ( sPlayer = source ), I can outputchatbox him and sPlayer element is still working but when i use: exports.system:doPlayerCommand( sPlayer ) it don't make any effect. function doPlayerCommand( player ) executeCommandHandler( "dance", player ) --it always return false from upper problem, anyway always works good end So, bug ?
coolman Posted December 24, 2011 Author Posted December 24, 2011 Yes, i called from other function in this same resource and it works. Maybe it is bug ?
Cadu12 Posted December 25, 2011 Posted December 25, 2011 No, itsnt bug. Did you added "" in your meta.xml? Learn more: https://wiki.multitheftauto.com/wiki/Resources
novo Posted December 25, 2011 Posted December 25, 2011 I think, don't get this because i'm not sure, that you can't execute a command handler from server on client. Here you have a code for client-side: function doPlayerCommand( player ) triggerServerEvent("onExecuteCommand", player ) end And a code for server-side: addCommandHandler("dance", function() --[[ Here you must add the full commandHandler function. ]]-- end ) addEvent("onExecuteCommand") addEventHandler("onExecuteCommand", function(player) executeCommandHandler( "dance", player ) end ) Try it and tell me what happens.
TAPL Posted December 25, 2011 Posted December 25, 2011 i trigger localplayer from client to server ( sPlayer = source ), I can outputchatbox him and sPlayer element is still working but when i use: exports.system:doPlayerCommand( sPlayer ) it don't make any effect. Don't do this sPlayer = source or this local sPlayer = source because this may buged, source is the element that the event originated from remember this: Each event has a source element so why you don't just use this?! exports.system:doPlayerCommand( source )
coolman Posted December 25, 2011 Author Posted December 25, 2011 Bad: local lPlayer = getLocalPlayer() ... triggerClientEvent( ..., lPlayer ) This way worked: local lPlayer = getLocalPlayer() ... triggerClientEvent( ..., getLocalPlayer())
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