Galton Posted March 3, 2015 Share Posted March 3, 2015 playerMoney = getPlayerMoney(PLAYER*) moneyM1000 = playerMoney -1000 moneyM3000 = playerMoney -3000 localplayer = getPlayerFromName (PLAYER*) addEvent("onBtn1",true) function setstyle15(PLAYER*) setPedFightingStyle (PLAYER*,15) end addEventHandler ("onBtn1", getRootElement(), setstyle15) I'm trying to make a gui which has 5 buttons, if you click them I want them to change your fighting style (they all give you different styles). I need to get the local player who clicks the button on GUI for which I typed "PLAYER*", everything else works without a problem so far. Thanks in advance. Link to comment
Bonsai Posted March 3, 2015 Share Posted March 3, 2015 localPlayer is predefined on clientside. Also, gui's are clientside, so it can't be used by anyone else than the local player, so you don't need to check who clicked. Link to comment
Galton Posted March 3, 2015 Author Share Posted March 3, 2015 localPlayer is predefined on clientside.Also, gui's are clientside, so it can't be used by anyone else than the local player, so you don't need to check who clicked. Thanks for the reply. This code is from a server-side script, I tried making it client-side but setPedFightingStyle wouldn't work. so I had to use addEvent and triggerServerEvent instead. Even if I can make it work in a client side script, I'd still like to learn how to define local player in a server-side script. Link to comment
Bonsai Posted March 3, 2015 Share Posted March 3, 2015 Ahh, you can just pass the player - "element" when triggering a server event. Just use it as the source. https://wiki.multitheftauto.com/wiki/TriggerServerEvent In that function which is called when you trigger that event you can simply use "source" or "client" to do stuff with the "local" player. setPedFightingStyle (source,15) --or client Link to comment
Galton Posted March 3, 2015 Author Share Posted March 3, 2015 Ahh, you can just pass the player - "element" when triggering a server event.Just use it as the source. https://wiki.multitheftauto.com/wiki/TriggerServerEvent In that function which is called when you trigger that event you can simply use "source" or "client" to do stuff with the "local" player. setPedFightingStyle (source,15) --or client setPedFightingStyle (client,15) works fine. this is how I defined playerMoney: function setstyle7 () local playerMoney = getPlayerMoney(client) local moneyM1000 = playerMoney -1000 local moneyM3000 = playerMoney -3000 if ( playerMoney > 3000 ) then setPedFightingStyle (client,7) setPlayerMoney (client, moneyM3000) outputChatBox ("test") else outputChatBox ("test2") end end I added local playerMoney = getPlayerMoney(client) local moneyM1000 = playerMoney -1000 local moneyM3000 = playerMoney -3000 in all functions. thank you for your help. 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