UnchiuDawg Posted October 17, 2018 Share Posted October 17, 2018 (edited) Hello, I have a little trouble understanding why attatching an event to the resourceRoot won't work on the serverside. Here's the script: -- serverside ballas1 = createPed (102, 1092, -1386, 14, 180,true) ballas2 = createPed (103, 1093, -1386, 14, 180,true) ballas3 = createPed (104, 1094, -1386, 14, 180,true) ballas4 = createPed (185, 1095, -1386, 14, 180,true) ballas5 = createPed (293, 1096, -1386, 14, 180,true) function sendPedVoices() triggerClientEvent("applyVoicesClient", source, ballas1, ballas2, ballas3, ballas4, ballas5) outputChatBox ( "#FF0000zzzzzz", source, 231, 217, 176, true ) end addEvent("sendPedVoices", true, true) addEventHandler("sendPedVoices", root, sendPedVoices) -- <<<<< attatched to root -- clientside function setPedVoices(ballas1, ballas2, ballas3, ballas4, ballas5) setPedVoice ( ballas1, "PED_TYPE_GANG", "VOICE_GNG_BALLAS1" ) setPedVoice ( ballas2, "PED_TYPE_GANG", "VOICE_GNG_BALLAS2" ) setPedVoice ( ballas3, "PED_TYPE_GANG", "VOICE_GNG_BALLAS3" ) setPedVoice ( ballas4, "PED_TYPE_GANG", "VOICE_GNG_BALLAS4" ) setPedVoice ( ballas5, "PED_TYPE_GANG", "VOICE_GNG_BALLAS5" ) end addEvent("applyVoicesClient", true, true) addEventHandler("applyVoicesClient", localPlayer, setPedVoices) function requestVoices() triggerServerEvent ( "sendPedVoices", localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, requestVoices) If I attatch the "sendPedVoices" event to the resourceRoot (instead of the root) it won't work. Is it simply not possible to do that or am I doing something wrong here? Edited October 17, 2018 by UnchiuDawg Link to comment
keymetaphore Posted October 17, 2018 Share Posted October 17, 2018 function setPedVoices(ballas1, ballas2, ballas3, ballas4, ballas5) setPedVoice ( ballas1, "PED_TYPE_GANG", "VOICE_GNG_BALLAS1" ) setPedVoice ( ballas2, "PED_TYPE_GANG", "VOICE_GNG_BALLAS2" ) setPedVoice ( ballas3, "PED_TYPE_GANG", "VOICE_GNG_BALLAS3" ) setPedVoice ( ballas4, "PED_TYPE_GANG", "VOICE_GNG_BALLAS4" ) setPedVoice ( ballas5, "PED_TYPE_GANG", "VOICE_GNG_BALLAS5" ) end addEvent("applyVoicesClient", true, true) addEventHandler("applyVoicesClient", resourceRoot, setPedVoices) -- Changed to resourceRoot, this will do the trick. function requestVoices() triggerServerEvent ( "sendPedVoices", localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, requestVoices) Link to comment
UnchiuDawg Posted October 17, 2018 Author Share Posted October 17, 2018 14 minutes ago, Biistamais said: function setPedVoices(ballas1, ballas2, ballas3, ballas4, ballas5) setPedVoice ( ballas1, "PED_TYPE_GANG", "VOICE_GNG_BALLAS1" ) setPedVoice ( ballas2, "PED_TYPE_GANG", "VOICE_GNG_BALLAS2" ) setPedVoice ( ballas3, "PED_TYPE_GANG", "VOICE_GNG_BALLAS3" ) setPedVoice ( ballas4, "PED_TYPE_GANG", "VOICE_GNG_BALLAS4" ) setPedVoice ( ballas5, "PED_TYPE_GANG", "VOICE_GNG_BALLAS5" ) end addEvent("applyVoicesClient", true, true) addEventHandler("applyVoicesClient", resourceRoot, setPedVoices) -- Changed to resourceRoot, this will do the trick. function requestVoices() triggerServerEvent ( "sendPedVoices", localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, requestVoices) I have tried it like that too, but it still won't work if on the serverside I attatch the event "sendPedVoices" to the resourceRoot, it still has to be attatched to the root. Link to comment
keymetaphore Posted October 17, 2018 Share Posted October 17, 2018 19 minutes ago, UnchiuDawg said: I have tried it like that too, but it still won't work if on the serverside I attatch the event "sendPedVoices" to the resourceRoot, it still has to be attatched to the root. function sendPedVoices() triggerClientEvent(source, "applyVoicesClient", resourceRoot, ballas1, ballas2, ballas3, ballas4, ballas5) outputChatBox ( "#FF0000zzzzzz", source, 231, 217, 176, true ) end addEvent("sendPedVoices", true, true) addEventHandler("sendPedVoices", resourceRoot, sendPedVoices) -- <<<<< attatched to root function requestVoices() triggerServerEvent ( "sendPedVoices", resourceRoot) end 1 Link to comment
Z4Zy Posted October 17, 2018 Share Posted October 17, 2018 1 minute ago, Biistamais said: function sendPedVoices() triggerClientEvent(source, "applyVoicesClient", resourceRoot, ballas1, ballas2, ballas3, ballas4, ballas5) outputChatBox ( "#FF0000zzzzzz", source, 231, 217, 176, true ) end addEvent("sendPedVoices", true, true) addEventHandler("sendPedVoices", resourceRoot, sendPedVoices) -- <<<<< attatched to root Hi ! what represents the 3rd argument [ true ] of "addEvent" ? Link to comment
keymetaphore Posted October 17, 2018 Share Posted October 17, 2018 1 minute ago, DeadthStrock said: Hi ! what represents the 3rd argument [ true ] of "addEvent" ? Just spotted another error. Well, the first argument of addEvent() is obviously the event name, the second one is allowRemoteTrigger, which basically allows it to be triggered remotely, from other files or resources, you should always keep it true unless for security reasons. The third argument is not necessary and shall be removed. Link to comment
UnchiuDawg Posted October 17, 2018 Author Share Posted October 17, 2018 4 minutes ago, Biistamais said: Just spotted another error. Well, the first argument of addEvent() is obviously the event name, the second one is allowRemoteTrigger, which basically allows it to be triggered remotely, from other files or resources, you should always keep it true unless for security reasons. The third argument is not necessary and shall be removed. Yeah I've added that argument by mistake, it shouldn't be there, I'll remove it. 9 minutes ago, Biistamais said: function sendPedVoices() triggerClientEvent(source, "applyVoicesClient", resourceRoot, ballas1, ballas2, ballas3, ballas4, ballas5) outputChatBox ( "#FF0000zzzzzz", source, 231, 217, 176, true ) end addEvent("sendPedVoices", true, true) addEventHandler("sendPedVoices", resourceRoot, sendPedVoices) -- <<<<< attatched to root function requestVoices() triggerServerEvent ( "sendPedVoices", resourceRoot) end Thank you for the help, it works properly now and I also understand what I did wrong ^^ 1 Link to comment
Z4Zy Posted October 17, 2018 Share Posted October 17, 2018 (edited) Edited October 17, 2018 by DeadthStrock Link to comment
UnchiuDawg Posted October 17, 2018 Author Share Posted October 17, 2018 1 minute ago, DeadthStrock said: -- serverside ballas1 = createPed (102, 1092, -1386, 14, 180,true) ballas2 = createPed (103, 1093, -1386, 14, 180,true) ballas3 = createPed (104, 1094, -1386, 14, 180,true) ballas4 = createPed (185, 1095, -1386, 14, 180,true) ballas5 = createPed (293, 1096, -1386, 14, 180,true) function sendPedVoices() triggerClientEvent("applyVoicesClient", source, ballas1, ballas2, ballas3, ballas4, ballas5) outputChatBox ( "#FF0000zzzzzz", source, 231, 217, 176, true ) end addEvent("sendPedVoices", true) addEventHandler("sendPedVoices", root, sendPedVoices) -- <<<<< attatched to root -- clientside function setPedVoices(ballas1, ballas2, ballas3, ballas4, ballas5) setPedVoice ( ballas1, "PED_TYPE_GANG", "VOICE_GNG_BALLAS1" ) setPedVoice ( ballas2, "PED_TYPE_GANG", "VOICE_GNG_BALLAS2" ) setPedVoice ( ballas3, "PED_TYPE_GANG", "VOICE_GNG_BALLAS3" ) setPedVoice ( ballas4, "PED_TYPE_GANG", "VOICE_GNG_BALLAS4" ) setPedVoice ( ballas5, "PED_TYPE_GANG", "VOICE_GNG_BALLAS5" ) end addEvent("applyVoicesClient", true) addEventHandler("applyVoicesClient", root, setPedVoices) function requestVoices() triggerServerEvent ( "sendPedVoices", localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, requestVoices) Check this out ! I've meant to attatch the event to the resourceRoot, not the root. It was already working when attatched to the root. Biistamais' method works the way I wanted it to be ^^ But thanks anyway 1 Link to comment
Moderators IIYAMA Posted October 17, 2018 Moderators Share Posted October 17, 2018 7 hours ago, DeadthStrock said: Hi ! what represents the 3rd argument [ true ] of "addEvent" ? 7 hours ago, Biistamais said: Just spotted another error. Well, the first argument of addEvent() is obviously the event name, the second one is allowRemoteTrigger, which basically allows it to be triggered remotely, from other files or resources, you should always keep it true unless for security reasons. The third argument is not necessary and shall be removed. Quote Optional Arguments allowRemoteTrigger: A boolean specifying whether this event can be called remotely using triggerClientEvent / triggerServerEvent or not. https://wiki.multitheftauto.com/wiki/AddEvent It is an option to prevent events, to trigger the handlers from either the client or server. If you put the option on a clientside script to false, it will ignore events triggered from serverside scripts. If you put the option on a serverside script to false, it will ignore events triggered from clientside scripts. It doesn't prevent triggering from other files(unless it is from the other [server/client]side) and it also doesn't prevent triggering from other resources. 7 hours ago, Biistamais said: you should always keep it true unless for security reasons. 1 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