GrinningTrout Posted May 16, 2016 Posted May 16, 2016 hi guys, i'm new here , and just want to know how do I know the errors in my client script . and don't understand that elements thing cuz sometimes for player I use source,theplayer,player , root, (i try them all) and sometimes none of them works (sorry about my English)
5150 Posted May 16, 2016 Posted May 16, 2016 use /debugscript 3 while youre in the server. it will tell you any errors in your script Paid Roleplay Mapper/Server Management - Message on forums or Discord for info Fluent with Owlgaming Code. Discord message for paid full set-ups and help My Discord: 5150#5150 (or .5150) Monky Gaming Roleplay/Adventure Discord (English players and servers interested in collaborating or partnering message me) https://discord.gg/SFBUHknpxy
swedishboy Posted May 16, 2016 Posted May 16, 2016 hi. https://wiki.multitheftauto.com/wiki/Ev ... ce_Element about errors and warnings https://wiki.multitheftauto.com/wiki/Debugging
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 ok thnx, last question can i write addEventHandler("onClientGUIClick", Button,armmor) in client script and the function armmor in server script ?
MACIEKW89 Posted May 16, 2016 Posted May 16, 2016 No, you can't. Try on server side with onPlayerClick event https://wiki.multitheftauto.com/wiki/OnPlayerClick .
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 function armmor() setPedArmor(source,50) takePlayerMoney(source,100) end addEventHandler("onPlayerClick",root,armmor,left,down,button) that work wherever i press, how can i make it work only when i press the button
#|_oskar_|# Posted May 16, 2016 Posted May 16, 2016 use triggerServerEvent لا اله الا انت سبحانك اني كنت من الظالمين My Group : https://www.facebook.com/groups/992678147519191/
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 use triggerServerEvent can you give me an example or add it to my script above i want work when i press button
#|_oskar_|# Posted May 16, 2016 Posted May 16, 2016 ok try this addEventHandler("onPlayerClick",root,armmor) لا اله الا انت سبحانك اني كنت من الظالمين My Group : https://www.facebook.com/groups/992678147519191/
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 ok try this addEventHandler("onPlayerClick",root,armmor) that works wherever i press
#|_oskar_|# Posted May 16, 2016 Posted May 16, 2016 -- #Client-side addEventHandler("onClientGUIClick",resourceRoot,function () if (source == Button_Name) then triggerServerEvent ( "onPlayerClick",localPlayer) end end) -- #Server-Side addEvent( "onPlayerClick", true ) addEventHandler( "onPlayerClick",resourceRoot,function () if (getPlayerMoney(source) > 100) then setPedArmor(source,50) takePlayerMoney(source,100) else outputChatBox ("you poor",source,150,0,0) end end) لا اله الا انت سبحانك اني كنت من الظالمين My Group : https://www.facebook.com/groups/992678147519191/
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 -- #Client-side addEventHandler("onClientGUIClick",resourceRoot,function () if (source == Button_Name) then triggerServerEvent ( "onPlayerClick",localPlayer) end end) -- #Server-Side addEvent( "onPlayerClick", true ) addEventHandler( "onPlayerClick",resourceRoot,function () if (getPlayerMoney(source) > 100) then setPedArmor(source,50) takePlayerMoney(source,100) else outputChatBox ("you poor",source,150,0,0) end end) well, not working...
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 --Client-side Button1 = guiCreateButton( 0.7, 0.3, 0.2, 0.1, "Outp11ut!", true ) function wuy() showCursor(true) end addCommandHandler("y",wuy) addEventHandler("onClientGUIClick",resourceRoot,function () if (source == Button1) then triggerServerEvent ( "onPlayerClick",localPlayer) end end) Server-Side addEvent( "onPlayerClick", true ) addEventHandler( "onPlayerClick",resourceRoot,function () if (getPlayerMoney(source) > 100) then setPedArmor(source,50) takePlayerMoney(source,100) else outputChatBox ("you poor",source,150,0,0) end end) triggerClientEvent ( "onClientGUIClick", root)
Anubhav Posted May 16, 2016 Posted May 16, 2016 addEvent( "onPlayerClick", true ) addEventHandler( "onPlayerClick",root,function () if (getPlayerMoney(source) > 100) then setPedArmor(source,50) takePlayerMoney(source,100) else outputChatBox ("you poor",source,150,0,0) end end) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 addEvent( "onPlayerClick", true ) addEventHandler( "onPlayerClick",root,function () if (getPlayerMoney(source) > 100) then setPedArmor(source,50) takePlayerMoney(source,100) else outputChatBox ("you poor",source,150,0,0) end end) ...work wherever i press
swedishboy Posted May 16, 2016 Posted May 16, 2016 (edited) I don't know what you exactly want but i made this.. server-side: function getArmor () local armor = getPlayerArmor(source) local money = getPlayerMoney(source) if money >= 100 and armor < 100 then setPedArmor(source,armor+50) takePlayerMoney(source, 100) elseif money >= 100 and armor >= 100 then outputChatBox("Already full armor", source, 255, 0, 0) elseif money < 100 then outputChatBox("Not enough money", source, 255, 0, 0) end end addEvent("onarmorb", true) addEventHandler("onarmorb", root, getArmor) client-side: mywindow = guiCreateWindow(564, 440, 169, 111, "", false) guiWindowSetSizable(mywindow, false) armorB = guiCreateButton(19, 26, 130, 42, "Armor", false, mywindow) closeB = guiCreateButton(42, 74, 86, 27, "Close", false, mywindow) guiSetVisible(mywindow, false) addCommandHandler("y", function () if guiGetVisible(mywindow) == false then guiSetVisible(mywindow, true) showCursor(true) end end ) addEventHandler("onClientGUIClick", closeB, function() guiSetVisible(mywindow,false) showCursor(false) end,false) addEventHandler("onClientGUIClick", armorB, function() triggerServerEvent("onarmorb", getLocalPlayer()) end,false) Use command /y Edited May 16, 2016 by Guest
GrinningTrout Posted May 16, 2016 Author Posted May 16, 2016 I don't know what you exactly want but i made this..server-side: function getArmor () local armor = getPlayerArmor(source) local money = getPlayerMoney(source) if money >= 100 and armor < 100 then setPedArmor(source,armor+50) takePlayerMoney(source, 100) elseif money >= 100 and armor >= 100 then outputChatBox("Already full armor", thePlayer, 255, 0, 0) elseif money < 100 then outputChatBox("Not enough money", thePlayer, 255, 0, 0) end end addEvent("onarmorb", true) addEventHandler("onarmorb", root, getArmor) client-side: mywindow = guiCreateWindow(564, 440, 169, 111, "", false) guiWindowSetSizable(mywindow, false) armorB = guiCreateButton(19, 26, 130, 42, "Armor", false, mywindow) closeB = guiCreateButton(42, 74, 86, 27, "Close", false, mywindow) guiSetVisible(mywindow, false) addCommandHandler("y", function () if guiGetVisible(mywindow) == false then guiSetVisible(mywindow, true) showCursor(true) end end ) addEventHandler("onClientGUIClick", closeB, function() guiSetVisible(mywindow,false) showCursor(false) end) addEventHandler("onClientGUIClick", armorB, function() triggerServerEvent("onarmorb", getLocalPlayer()) end) Use command /y finally, thnx
#|_oskar_|# Posted May 16, 2016 Posted May 16, 2016 use this addEventHandler("onClientGUIClick", closeB, function() guiSetVisible(mywindow,false) showCursor(false) end,false) ---- addEventHandler("onClientGUIClick", armorB, function() triggerServerEvent("onarmorb", getLocalPlayer()) end,false) or addEventHandler("onClientGUIClick",root,function () if (source == armorB) then triggerServerEvent("onarmorb", getLocalPlayer()) elseif (source == closeB) then guiSetVisible(mywindow,false) showCursor(false) end end) لا اله الا انت سبحانك اني كنت من الظالمين My Group : https://www.facebook.com/groups/992678147519191/
swedishboy Posted May 16, 2016 Posted May 16, 2016 Ye you can do it that way too, it's up to him waht he want to use. And btw @GrinningTrout change the outputChatBox ''thePlayer'' to ''source'' or the whole server will see the output
Feher Posted May 16, 2016 Posted May 16, 2016 Hey, "onPlayerClick" is an existing Server-sided event, you have to find own event names for your events. --Client-side Button1 = guiCreateButton( 0.7, 0.3, 0.2, 0.1, "Outp11ut!", true ) function wuy() showCursor(true) end addCommandHandler("y",wuy) addEventHandler("onClientGUIClick",root,function () if (source == Button1) then triggerServerEvent ( "onPlayerClicko",localPlayer) end end) -- Server-side addEvent( "onPlayerClicko", true ) addEventHandler( "onPlayerClicko",root,function () if (getPlayerMoney(source) > 100) then setPedArmor(source,50) takePlayerMoney(source,100) else outputChatBox ("you poor",source,150,0,0) end end)
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