GrinningTrout Posted May 16, 2016 Share 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) Link to comment
5150 Posted May 16, 2016 Share Posted May 16, 2016 use /debugscript 3 while youre in the server. it will tell you any errors in your script Link to comment
swedishboy Posted May 16, 2016 Share Posted May 16, 2016 hi. https://wiki.multitheftauto.com/wiki/Ev ... ce_Element about errors and warnings https://wiki.multitheftauto.com/wiki/Debugging Link to comment
GrinningTrout Posted May 16, 2016 Author Share 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 ? Link to comment
MACIEKW89 Posted May 16, 2016 Share Posted May 16, 2016 No, you can't. Try on server side with onPlayerClick event https://wiki.multitheftauto.com/wiki/OnPlayerClick . Link to comment
GrinningTrout Posted May 16, 2016 Author Share 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 Link to comment
GrinningTrout Posted May 16, 2016 Author Share 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 Link to comment
#|_oskar_|# Posted May 16, 2016 Share Posted May 16, 2016 ok try this addEventHandler("onPlayerClick",root,armmor) Link to comment
GrinningTrout Posted May 16, 2016 Author Share Posted May 16, 2016 ok try this addEventHandler("onPlayerClick",root,armmor) that works wherever i press Link to comment
#|_oskar_|# Posted May 16, 2016 Share 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) Link to comment
GrinningTrout Posted May 16, 2016 Author Share 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... Link to comment
GrinningTrout Posted May 16, 2016 Author Share 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) Link to comment
Anubhav Posted May 16, 2016 Share 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) Link to comment
GrinningTrout Posted May 16, 2016 Author Share 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 Link to comment
swedishboy Posted May 16, 2016 Share 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 Link to comment
GrinningTrout Posted May 16, 2016 Author Share 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 Link to comment
#|_oskar_|# Posted May 16, 2016 Share 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) Link to comment
swedishboy Posted May 16, 2016 Share 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 Link to comment
Feher Posted May 16, 2016 Share 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) 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