Simi23 Posted September 12, 2016 Share Posted September 12, 2016 (edited) Hello! I have make a duty script, and its doesn't working. Can anyone solve it? Server: addEvent("addArmor", true) function addArmor() setPedArmor(source, 100) end addEventHandler("addArmor", getRootElement(), addArmor) function pdduty(player) local x, y, z = getElementPosition(player) local pickup = createPickup(x + 3, y, z, 3, 1242) colshape = getElementColShape(pickup) addEventHandler("onColShapeHit", colshape, openwindow) addEventHandler("onColShapeLeave", colshape, closewindow) addEventHandler("onPickupUse", pickup, function() cancelEvent() end) end addCommandHandler("pdduty", pdduty) function openwindow(hitElement, matchingDimension) if matchingDimension and getElementType(hitElement) == "player" then triggerClientEvent("openwindow", hitElement) end end function closewindow(hitElement, matchingDimension) if matchingDimension and getElementType(hitElement) == "player" then triggerClientEvent("closewindow", hitElement) end end Client: sx, sy = guiGetScreenSize() addEvent("openwindow", true) function changeDuty() if getElementData(lPlayer, "duty", "0") then lPlayer = getLocalPlayer() givePedWeapon(lPlayer, 24) givePedWeapon(lPlayer, 31, 180) triggerServerEvent("addArmor", getRootElement()) setElementData(lPlayer, "duty", "1") end end function draw() dxDrawRectangle(sx * 0.4, sy * 0.65, sx * 0.2, sy * 1.0, tocolor(0,0,0,150)) dxDrawText("Duty: [E]", sx * 0.45, sy * 0.7) end function openwindow() addEventHandler("onClientRender", getRootElement(), draw) bindKey("e", "down", changeDuty) end addEventHandler("openwindow", getRootElement(), openwindow) addEvent("closewindow", true) function closewindow() removeEventHandler("onClientRender", getRootElement(), draw) unbindKey("e", "down", changeDuty) end addEventHandler("closewindow", getRootElement(), closewindow) The meta doesn't have any problems, for sure. Edited September 12, 2016 by Simi23 Link to comment
Captain Cody Posted September 12, 2016 Share Posted September 12, 2016 Please update to the new code system using the <> in the editor window. Link to comment
Simi23 Posted September 12, 2016 Author Share Posted September 12, 2016 Ready to go My first post Link to comment
Gravestone Posted September 13, 2016 Share Posted September 13, 2016 Tell us what errors you're facing. Link to comment
Simi23 Posted September 13, 2016 Author Share Posted September 13, 2016 What i think is: If i hit the placed collision of the pickup, it shows me the window, and i can press e to receive my armor, deagle, and an M4. But if i hit that pickup, it happens nothing. I think because pickups has no collision. Link to comment
EstrategiaGTA Posted September 13, 2016 Share Posted September 13, 2016 Use onPickupHit Link to comment
Simi23 Posted September 13, 2016 Author Share Posted September 13, 2016 I know, but pickups have no "onPickupLeave" event. I'm think i am gonna use a hidden marker and make the pickup do nothing. 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