HassoN Posted July 22, 2019 Share Posted July 22, 2019 Just now, selam said: @HassoN Thanks, so as I see I have to use client to make my peds immortal right? You may still use server side to create the ped then cancel its damage in client side. Link to comment
selam Posted July 22, 2019 Author Share Posted July 22, 2019 Just now, HassoN said: You may still use server side to create the ped then cancel its damage in client side. Hmm, what about meta.xml then? Link to comment
MilWaxQ Posted July 22, 2019 Share Posted July 22, 2019 Just now, selam said: Hmm, what about meta.xml then? <info author="Admin" type="script" name="balik" description="balikcilik"/> <script src="fish_server.Lua" type="server"/> <script src="fish_client.Lua" type="client"/> Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 @HassoN Hello again, now I am trying to create an marker in front of the ped, but when I try, even ped script doesnt work, why? function PedLoad(ped) ped = createPed ( 36, 1623.5, 576.70001220703, 1.7999999523163 ) setElementFrozen( ped, true ) addEventHandler("onClientPedDamage", ped, cancelEvent) end addEventHandler("onClientResourceStart", resourceRoot, PedLoad) -- Marker coords -- X: 1623.5999755859 Y: 577.59997558594 Z: 0.79999995231628 function MarkerLoad(marker) marker = createMarker ( 1623.5999755859, 577.59997558594, 0.79999995231628 [, string theType = "cylinder", ] ) end Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 @HassoN Ok nvm, I fixed the problem Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 (edited) @HassoN I've created a GUI, now I am trying to do that, when my player enters the marker, he will see GUI, but I can't. Can you help me? marker = createMarker (1623.5999755859, 577.59997558594, 0.79999995231628, "cylinder", 1.2, 255, 0, 0, 140 ) function playermarkerhit(markerHit) end addEventHandler( "onPlayerMarkerHit", resourceRoot, markerHit ) GUIEditor = { button = {}, window = {}, edit = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(448, 230, 504, 330, "Fisherman", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.85) GUIEditor.label[1] = guiCreateLabel(7, 33, 222, 38, " Fisherman: Hello! Get some fish food!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(10, 83, 105, 33, " x10 Food = 300$", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.button[1] = guiCreateButton(22, 133, 122, 80, " BUY FOODS(10)", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(283, 79, 192, 55, "Do you have enough fishes to sell?\n Let me have!", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(293, 33, 68, 20, " Fisherman:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[4], "default-bold-small") GUIEditor.button[2] = guiCreateButton(278, 134, 192, 73, " SELL FISHES", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(113, 266, 283, 18, " Note! You can buy maximum 20 foods for per deal", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[5], "default-bold-small") GUIEditor.edit[1] = guiCreateEdit(476, -28888, 18, 768, "", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(444, -31241, 30, 768, "", false, GUIEditor.window[1]) end ) Edited July 23, 2019 by selam Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 (edited) 11 minutes ago, selam said: @HassoN I've created a GUI, now I am trying to do that, when my player enters the marker, he will see GUI, but I can't. Can you help me? marker = createMarker (1623.5999755859, 577.59997558594, 0.79999995231628, "cylinder", 1.2, 255, 0, 0, 140 )function playermarkerhit(markerHit) endaddEventHandler( "onPlayerMarkerHit", resourceRoot, markerHit )GUIEditor = { button = {}, window = {}, edit = {}, label = {}}addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(448, 230, 504, 330, "Fisherman", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.85) GUIEditor.label[1] = guiCreateLabel(7, 33, 222, 38, " Fisherman: Hello! Get some fish food!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(10, 83, 105, 33, " x10 Food = 300$", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.button[1] = guiCreateButton(22, 133, 122, 80, " BUY FOODS(10)", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(283, 79, 192, 55, "Do you have enough fishes to sell? Let me have!", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(293, 33, 68, 20, " Fisherman:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[4], "default-bold-small") GUIEditor.button[2] = guiCreateButton(278, 134, 192, 73, " SELL FISHES", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(113, 266, 283, 18, " Note! You can buy maximum 20 foods for per deal", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[5], "default-bold-small") GUIEditor.edit[1] = guiCreateEdit(476, -28888, 18, 768, "", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(444, -31241, 30, 768, "", false, GUIEditor.window[1]) end) marker = createMarker (1623.5999755859, 577.59997558594, 0.79999995231628, "cylinder", 1.2, 255, 0, 0, 140 ) function markerHit(plr) if (plr ~= localPlayer) then return false end guiSetVisible(GUIEditor.window[1], true) showCursor(true) end addEventHandler( "onClientMarkerHit", marker, markerHit) GUIEditor = { button = {}, window = {}, edit = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(448, 230, 504, 330, "Fisherman", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.85) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 33, 222, 38, " Fisherman: Hello! Get some fish food!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(10, 83, 105, 33, " x10 Food = 300$", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.button[1] = guiCreateButton(22, 133, 122, 80, " BUY FOODS(10)", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(283, 79, 192, 55, "Do you have enough fishes to sell?\n Let me have!", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(293, 33, 68, 20, " Fisherman:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[4], "default-bold-small") GUIEditor.button[2] = guiCreateButton(278, 134, 192, 73, " SELL FISHES", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(113, 266, 283, 18, " Note! You can buy maximum 20 foods for per deal", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[5], "default-bold-small") GUIEditor.edit[1] = guiCreateEdit(476, -28888, 18, 768, "", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(444, -31241, 30, 768, "", false, GUIEditor.window[1]) end ) Edited July 23, 2019 by HassoN Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 @HassoN Its working thanks, and do you know how can I add close button to the gui window? I did not find on editor how to. Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 You just add a normal button then name it "Close" Then you use addEventHandler -- onClientGUIClick guiSetVisible -- hide the GUI showCursor -- hide the cursor Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 @HassoN And now your code is not working, 1 hour ago, HassoN said: marker = createMarker (1623.5999755859, 577.59997558594, 0.79999995231628, "cylinder", 1.2, 255, 0, 0, 140 )function markerHit(plr) if (plr ~= localPlayer) then return false end guiSetVisible(GUIEditor.window[1], true) showCursor(true)endaddEventHandler( "onClientMarkerHit", marker, markerHit)GUIEditor = { button = {}, window = {}, edit = {}, label = {}}addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(448, 230, 504, 330, "Fisherman", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.85) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 33, 222, 38, " Fisherman: Hello! Get some fish food!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(10, 83, 105, 33, " x10 Food = 300$", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.button[1] = guiCreateButton(22, 133, 122, 80, " BUY FOODS(10)", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(283, 79, 192, 55, "Do you have enough fishes to sell?\n Let me have!", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(293, 33, 68, 20, " Fisherman:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[4], "default-bold-small") GUIEditor.button[2] = guiCreateButton(278, 134, 192, 73, " SELL FISHES", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(113, 266, 283, 18, " Note! You can buy maximum 20 foods for per deal", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[5], "default-bold-small") GUIEditor.edit[1] = guiCreateEdit(476, -28888, 18, 768, "", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(444, -31241, 30, 768, "", false, GUIEditor.window[1]) end) Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 1 minute ago, selam said: @HassoN And now your code is not working, Show me what you've done along with /debugscript 3. Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 23 minutes ago, HassoN said: You just add a normal button then name it "Close" Then you use addEventHandler -- onClientGUIClickguiSetVisible -- hide the GUIshowCursor -- hide the cursor Its very hard for me to, can you do it? I added "addeventhandler" to below of the close button line, but I dont know rest, what to do. Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 1 minute ago, selam said: Its very hard for me to, can you do it? I added "addeventhandler" to below of the close button line, but I dont know rest, what to do. Basically it should be something like: addEventHandler("onClientGUIClick", resourceRoot, function() if (source == closeButton) then -- replace closeButton with your button name. guiSetVisible(window, false) -- replace window with your window name. showCursor(false) end end) And next time check the examples on wiki before asking because most of the times the examples are really clear to understand. Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 @HassoN Hello, I know that wiki is helpful but its even really hard for guys like me, that is why I am asking you manually. Well, I tried to do something by looking from wiki but not working :D I want to buy fish foods when player clicks the "buy" button. This is the code im using but not working addEventHandler( "onClientGUIClick", resourceRoot, function() if (source == GUIEditor.button[1]) then -- The button to buy guiSetVisible(GUIEditor.window[1], true) -- The window to buy showCursor(true) end end) function() local money = getPlayerMoney(getLocalPlayer( )) if (money >= 300) then outputChatBox("You have bought a fish food.") else outputChatBox("You don't have enough money.") end Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 4 minutes ago, selam said: @HassoN Hello, I know that wiki is helpful but its even really hard for guys like me, that is why I am asking you manually. Well, I tried to do something by looking from wiki but not working I want to buy fish foods when player clicks the "buy" button. This is the code im using but not working addEventHandler( "onClientGUIClick", resourceRoot, function() if (source == GUIEditor.button[1]) then -- The button to buy guiSetVisible(GUIEditor.window[1], true) -- The window to buy showCursor(true) end end)function() local money = getPlayerMoney(getLocalPlayer( )) if (money >= 300) then outputChatBox("You have bought a fish food.") else outputChatBox("You don't have enough money.") end You need to name your function and call it when 'buy' button is clicked. addEventHandler( "onClientGUIClick", resourceRoot, function() if (source == GUIEditor.button[1]) then -- The button to buy guiSetVisible(GUIEditor.window[1], true) -- The window to buy showCursor(true) elseif (source == buyButton) then -- add your button to buy buyFish() end end) function buyFish() local money = getPlayerMoney(getLocalPlayer( )) if (money >= 300) then outputChatBox("You have bought a fish food.") else outputChatBox("You don't have enough money.") end Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 @HassoN Your code was not working( all script, ped and markers too ), error was saying "end" expected at line 65, but I fixed it. The main problem is, I still cant buy foods, I mean my money doesnt subtract. Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 10 minutes ago, selam said: @HassoN Your code was not working( all script, ped and markers too ), error was saying "end" expected at line 65, but I fixed it. The main problem is, I still cant buy foods, I mean my money doesnt subtract. Ugh, it wasn't actually my bad, I copied your code without making attention. You forgot to add an 'end' to your 2nd function. The money doesn't subtract because you obviously didn't add: takePlayerMoney Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 Just now, HassoN said: Ugh, it wasn't actually my bad, I copied your code without making attention. You forgot to add an 'end' to your 2nd function. The money doesn't subtract because you obviously didn't add: takePlayerMoney function buyFish() local money = takePlayerMoney( localPlayer, 300 ) if (money >= 300) then outputChatBox("You have bought a fish food.") else outputChatBox("You don't have enough money.") end end end) This is the code, and still not working Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 (edited) -- client side addEventHandler( "onClientGUIClick", resourceRoot, function() if (source == GUIEditor.button[1]) then -- The button to buy guiSetVisible(GUIEditor.window[1], true) -- The window to buy showCursor(true) elseif (source == buyButton) then -- add your button to buy buyFish() end end) function buyFish() local money = getPlayerMoney(localPlayer) if (money >= 300) then outputChatBox("You have bought a fish food.") triggerServerEvent("buyFish", resourceRoot) else outputChatBox("You don't have enough money.") end end -- server side function buyFish() takePlayerMoney(client, 300) end addEvent("buyFish", true) addEventHandler("buyFish", root, buyFish) The reason behind using server side to take the money is because money in client side is not synced with the server. Edited July 23, 2019 by HassoN Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 (edited) 11 minutes ago, HassoN said: -- client sideaddEventHandler( "onClientGUIClick", resourceRoot,function() if (source == GUIEditor.button[1]) then -- The button to buy guiSetVisible(GUIEditor.window[1], true) -- The window to buy showCursor(true) elseif (source == buyButton) then -- add your button to buy buyFish() endend) function buyFish() local money = getPlayerMoney(localPlayer) if (money >= 300) then outputChatBox("You have bought a fish food.") triggerServerEvent("buyFish", resourceRoot) else outputChatBox("You don't have enough money.") endend-- server sidefunction buyFish() takePlayerMoney(client, 300)endaddEvent("buyFish", true)addEventHandler("buyFish", root, buyFish) The reason behind using server side to take the money is because money in client side is not synced with the server. Copy pasted this, but it says unexpected symbol near ' ( line 80 ) Edited July 23, 2019 by selam Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 Just now, selam said: Copy pasted this, but it says unexpected symbol near ' ( line 80 ) Invisible character *thanks to the forum*. Try to go to line 80 and try to delete the end of the line. Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 Just now, HassoN said: Invisible character *thanks to the forum*. Try to go to line 80 and try to delete the end of the line. Line 80 is addEventHandler("buyFish", root, buyFish) And when I delete it, I still cannot buy Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 1 minute ago, selam said: Line 80 is addEventHandler("buyFish", root, buyFish) And when I delete it, I still cannot buy I said delete the end of the line. Not the whole line. Try to search for the invisible character somewhere at the line 80. Link to comment
selam Posted July 23, 2019 Author Share Posted July 23, 2019 1 minute ago, HassoN said: I said delete the end of the line. Not the whole line. Try to search for the invisible character somewhere at the line 80. I deleted end of the line " ) Not works. There is no invisible character. Link to comment
DNL291 Posted July 23, 2019 Share Posted July 23, 2019 By looking at the code I see no erros. It seems to be a forum bug when you copy & paste code. Try from here: https://pastebin.com/iK2iSa9M 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