LiOneLMeSsIShoT Posted November 28, 2013 Share Posted November 28, 2013 Alright first..the script got problem...when i try to click on button "get Reward" and i have the bag...it says the message after Else....if i haven't the bag..it says the else message too..and not giving any money or anything... the second problem: when i hit the marker...my another gui for the weapon shop be shown too...so when i hit any marker the both of guis be shown..how to fix this? and thanks server side: local pbags = { {2293.154296875, 561.470703125, 7.78125}, } briefcaseMarker = createMarker(2291.1999511719, 537, 0.80000001192093, "cylinder", 1.5, 255, 0, 0) x, y, z = unpack(pbags[math.random(#pbags)]) baga = createPickup(x, y, z, 3, 1210) function Marker (hitPlayer) triggerClientEvent(hitPlayer, "Marker", getRootElement(), hitPlayer) end addEventHandler ("onMarkerHit",briefcaseMarker, Marker) function onPickupHit(player) if source == baga then if not isPedInVehicle(player) and not isPedDead(player) then bagb = createObject(1210, 0, 0, 0) exports.bone_attach:attachElementToBone(bagb,player,12,0,0.1,0.3,0,180,0) destroyElement(source) end end end addEventHandler("onPickupHit", root, onPickupHit) function onBtnClick(player) local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == player then local money = math.random(1000, 2000) givePlayerMoney(player, money) destroyElement(bagb) triggerClientEvent(source,"WarningText",getRootElement(),"reward","You have rewarded from the dealer") else triggerClientEvent(source,"WarningText",getRootElement(),"reward","You Must get the briefcase of weapons First!") end end addEvent ("reward", true) addEventHandler ("reward", getRootElement(), onBtnClick) function onPlayerQuit() local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == source then destroyElement(bagb) local x, y, z = getElementPosition(source) baga = createPickup(x, y, z, 3, 1210) end end addEventHandler("onPlayerQuit", root, onPlayerQuit) client side: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(319, 155, 640, 434, "Weapon Briefcase Dealer", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF0B21F2") guiSetVisible (GUIEditor.window[1], false) Close = guiCreateButton(505, 372, 115, 45, "Close", false, GUIEditor.window[1]) guiSetFont(Close, "default-bold-small") guiSetProperty(Close, "NormalTextColour", "FF6A9470") GUIEditor.label[1] = guiCreateLabel(118, 47, 391, 16, "If you found a Briefcase of weapons get it here and get your Rewards!", false, GUIEditor.window[1]) guiLabelSetColor(GUIEditor.label[1], 254, 0, 0) GUIEditor.staticimage[1] = guiCreateStaticImage(53, 84, 538, 153, ":Jobs_System/images/briefcase.png", false, GUIEditor.window[1]) Rewards = guiCreateButton(229, 276, 160, 67, "Get Your Rewards", false, GUIEditor.window[1]) Warning = guiCreateLabel(4, 240, 632, 34, "", false, GUIEditor.window[1]) guiSetFont(Warning, "default-bold-small") guiLabelSetColor(Warning, 253, 0, 5) guiLabelSetHorizontalAlign(Warning, "center", false) guiLabelSetVerticalAlign(Warning, "center") ---handlers addEventHandler ("onClientGUIClick", Rewards, onRewardButton, false) addEventHandler ("onClientGUIClick", Close, CloseBtn, false) end ) function Marker () guiSetVisible (GUIEditor.window[1], true) showCursor (true) end addEvent ("Marker", true) addEventHandler ("Marker", getRootElement(), Marker) function onRewardButton (button,state) if (button == "left" and state == "up") then triggerServerEvent ("reward", getLocalPlayer()) end end function Error_msg (Tab,Text) if Tab == "reward" then guiSetText (Warning, tostring(Text)) setTimer(function() guiSetText(Warning, "") end, 25000, 1) end end addEvent ("WarningText", true) addEventHandler ("WarningText", getRootElement(), Error_msg) function CloseBtn () guiSetVisible (GUIEditor.window[1], false) showCursor (false) end Link to comment
LiOneLMeSsIShoT Posted November 28, 2013 Author Share Posted November 28, 2013 C'mon guys i'm really need your help! Link to comment
Woovie Posted November 29, 2013 Share Posted November 29, 2013 onMarkerHit root element is the marker that was hit. So use 'source' to detect which marker was hit. You could use setElementData on the marker to give it some unique information to know which one it is. Not sure about the first issue, I may take a look at it at another point when my mind is working a bit better. You may have to delay it a bit with a timer maybe. Link to comment
TAPL Posted November 29, 2013 Share Posted November 29, 2013 Server Side: local pbags = { {2293.154, 561.47, 7.78}, } briefcaseMarker = createMarker(2291.2, 537, 0.8, "cylinder", 1.5, 255, 0, 0) x, y, z = unpack(pbags[math.random(#pbags)]) baga = createPickup(x, y, z, 3, 1210) function Marker(player) if getElementType(player) == "player" then triggerClientEvent(player, "briefcaseMarker", player) end end addEventHandler("onMarkerHit", briefcaseMarker, Marker) function onPickupHit(player) if source == baga then if not isPedInVehicle(player) and not isPedDead(player) then bagb = createObject(1210, 0, 0, 0) exports.bone_attach:attachElementToBone(bagb,player,12,0,0.1,0.3,0,180,0) destroyElement(source) end end end addEventHandler("onPickupHit", root, onPickupHit) function onBtnClick() local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == source then local money = math.random(1000, 2000) givePlayerMoney(source, money) destroyElement(bagb) triggerClientEvent(source, "WarningText", source, "reward", "You have rewarded from the dealer") else triggerClientEvent(source, "WarningText", source, "reward", "You Must get the briefcase of weapons First!") end end addEvent("reward", true) addEventHandler ("reward", root, onBtnClick) function onPlayerQuit() local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == source then destroyElement(bagb) local x, y, z = getElementPosition(source) baga = createPickup(x, y, z, 3, 1210) end end addEventHandler("onPlayerQuit", root, onPlayerQuit) Client Side: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(319, 155, 640, 434, "Weapon Briefcase Dealer", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF0B21F2") guiSetVisible (GUIEditor.window[1], false) Close = guiCreateButton(505, 372, 115, 45, "Close", false, GUIEditor.window[1]) guiSetFont(Close, "default-bold-small") guiSetProperty(Close, "NormalTextColour", "FF6A9470") GUIEditor.label[1] = guiCreateLabel(118, 47, 391, 16, "If you found a Briefcase of weapons get it here and get your Rewards!", false, GUIEditor.window[1]) guiLabelSetColor(GUIEditor.label[1], 254, 0, 0) GUIEditor.staticimage[1] = guiCreateStaticImage(53, 84, 538, 153, ":Jobs_System/images/briefcase.png", false, GUIEditor.window[1]) Rewards = guiCreateButton(229, 276, 160, 67, "Get Your Rewards", false, GUIEditor.window[1]) Warning = guiCreateLabel(4, 240, 632, 34, "", false, GUIEditor.window[1]) guiSetFont(Warning, "default-bold-small") guiLabelSetColor(Warning, 253, 0, 5) guiLabelSetHorizontalAlign(Warning, "center", false) guiLabelSetVerticalAlign(Warning, "center") ---handlers addEventHandler ("onClientGUIClick", Rewards, onRewardButton, false) addEventHandler ("onClientGUIClick", Close, CloseBtn, false) end ) function Marker() guiSetVisible(GUIEditor.window[1], true) showCursor(true) end addEvent("briefcaseMarker", true) addEventHandler("briefcaseMarker", root, Marker) function onRewardButton(button,state) if (button == "left" and state == "up") then triggerServerEvent("reward", localPlayer) end end function Error_msg(Tab,Text) if Tab == "reward" then guiSetText (Warning, Text) if isTimer(iR) then killTimer(iR) end iR = setTimer(function() guiSetText(Warning, "") end, 25000, 1) end end addEvent("WarningText", true) addEventHandler("WarningText", getRootElement(), Error_msg) function CloseBtn() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end And please when you copy the code, first hide the line number from the button (LINE NUMBER ON/OF) also use (SELECT ALL) so you don't get ugly space in your code each time you copy it. Link to comment
LiOneLMeSsIShoT Posted November 29, 2013 Author Share Posted November 29, 2013 Server Side: local pbags = { {2293.154, 561.47, 7.78}, } briefcaseMarker = createMarker(2291.2, 537, 0.8, "cylinder", 1.5, 255, 0, 0) x, y, z = unpack(pbags[math.random(#pbags)]) baga = createPickup(x, y, z, 3, 1210) function Marker(player) if getElementType(player) == "player" then triggerClientEvent(player, "briefcaseMarker", player) end end addEventHandler("onMarkerHit", briefcaseMarker, Marker) function onPickupHit(player) if source == baga then if not isPedInVehicle(player) and not isPedDead(player) then bagb = createObject(1210, 0, 0, 0) exports.bone_attach:attachElementToBone(bagb,player,12,0,0.1,0.3,0,180,0) destroyElement(source) end end end addEventHandler("onPickupHit", root, onPickupHit) function onBtnClick() local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == source then local money = math.random(1000, 2000) givePlayerMoney(source, money) destroyElement(bagb) triggerClientEvent(source, "WarningText", source, "reward", "You have rewarded from the dealer") else triggerClientEvent(source, "WarningText", source, "reward", "You Must get the briefcase of weapons First!") end end addEvent("reward", true) addEventHandler ("reward", root, onBtnClick) function onPlayerQuit() local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == source then destroyElement(bagb) local x, y, z = getElementPosition(source) baga = createPickup(x, y, z, 3, 1210) end end addEventHandler("onPlayerQuit", root, onPlayerQuit) Client Side: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(319, 155, 640, 434, "Weapon Briefcase Dealer", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF0B21F2") guiSetVisible (GUIEditor.window[1], false) Close = guiCreateButton(505, 372, 115, 45, "Close", false, GUIEditor.window[1]) guiSetFont(Close, "default-bold-small") guiSetProperty(Close, "NormalTextColour", "FF6A9470") GUIEditor.label[1] = guiCreateLabel(118, 47, 391, 16, "If you found a Briefcase of weapons get it here and get your Rewards!", false, GUIEditor.window[1]) guiLabelSetColor(GUIEditor.label[1], 254, 0, 0) GUIEditor.staticimage[1] = guiCreateStaticImage(53, 84, 538, 153, ":Jobs_System/images/briefcase.png", false, GUIEditor.window[1]) Rewards = guiCreateButton(229, 276, 160, 67, "Get Your Rewards", false, GUIEditor.window[1]) Warning = guiCreateLabel(4, 240, 632, 34, "", false, GUIEditor.window[1]) guiSetFont(Warning, "default-bold-small") guiLabelSetColor(Warning, 253, 0, 5) guiLabelSetHorizontalAlign(Warning, "center", false) guiLabelSetVerticalAlign(Warning, "center") ---handlers addEventHandler ("onClientGUIClick", Rewards, onRewardButton, false) addEventHandler ("onClientGUIClick", Close, CloseBtn, false) end ) function Marker() guiSetVisible(GUIEditor.window[1], true) showCursor(true) end addEvent("briefcaseMarker", true) addEventHandler("briefcaseMarker", root, Marker) function onRewardButton(button,state) if (button == "left" and state == "up") then triggerServerEvent("reward", localPlayer) end end function Error_msg(Tab,Text) if Tab == "reward" then guiSetText (Warning, Text) if isTimer(iR) then killTimer(iR) end iR = setTimer(function() guiSetText(Warning, "") end, 25000, 1) end end addEvent("WarningText", true) addEventHandler("WarningText", getRootElement(), Error_msg) function CloseBtn() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end And please when you copy the code, first hide the line number from the button (LINE NUMBER ON/OF) also use (SELECT ALL) so you don't get ugly space in your code each time you copy it. Cool..Thanks..but may you tell me what the error was with? Link to comment
TAPL Posted November 29, 2013 Share Posted November 29, 2013 when i hit the marker...my another gui for the weapon shop be shown too...so when i hit any marker the both of guis be shown..how to fix this? I changed the event name "Marker" to "briefcaseMarker" because you have another script while use same event name. Also i added element type checker, and added timer checker. player here not defined as you didn't pass it in triggerServerEvent. function onBtnClick(player) local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == player then local money = math.random(1000, 2000) givePlayerMoney(player, money) destroyElement(bagb) triggerClientEvent(source,"WarningText",getRootElement(),"reward","You have rewarded from the dealer") else triggerClientEvent(source,"WarningText",getRootElement(),"reward","You Must get the briefcase of weapons First!") end end addEvent ("reward", true) addEventHandler ("reward", getRootElement(), onBtnClick) This is how it should be: function onBtnClick() local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) if atthedTo == source then local money = math.random(1000, 2000) givePlayerMoney(source, money) destroyElement(bagb) triggerClientEvent(source, "WarningText", source, "reward", "You have rewarded from the dealer") else triggerClientEvent(source, "WarningText", source, "reward", "You Must get the briefcase of weapons First!") end end addEvent("reward", true) addEventHandler ("reward", root, onBtnClick) 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