damien111 Posted January 5, 2013 Share Posted January 5, 2013 I am trying to make a robber script. I made it so it checks if the player has the skin id 29 and if it does it triggers a event which creates a marker to go to to get money, which triggers the house event again, and so forth. I can not see any reasons why it wouldn't work. Thanks in advanced. Heres the code Client local robberHouses = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} -- Messi Put coord In This Table pl0x } function unpackRobberHouses () return unpack ( robberHouses [ math.random ( #robberHouses ) ] ) end addEvent ( "createHouse", true ) function createHouses () x, y, z = unpackRobberHouses () robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) end addEventHandler ( "createHouse", root, createHouses ) addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then triggerServerEvent ( "payPlayer", localPlayer ) destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) triggerEvent ( "createHouse", localPlayer ) end end ) addEventHandler ( "onResourceStart", getRootElement(), function() local rob = getElementModel ( source ) if rob == 29 then triggerEvent ( "createHouse", localPlayer ) end end) Server addEvent ( "payPlayer", true ) function givePlayerRobPay () money = math.random ( 350, 1020 ) givePlayerMoney ( source, money ) outputChatBox ( "You succesfully robbed $" ..money, source ) end addEventHandler ( "givePlayerPay", root, givePlayerRobPay ) Link to comment
Castillo Posted January 5, 2013 Share Posted January 5, 2013 addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) local rob = getElementModel ( localPlayer ) if ( rob == 29 ) then triggerEvent ( "createHouse", localPlayer ) end end ) Link to comment
Baseplate Posted January 5, 2013 Share Posted January 5, 2013 local robberHouses = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} -- Messi Put coord In This Table pl0x } function unpackRobberHouses () return unpack ( robberHouses [ math.random ( #robberHouses ) ] ) end addEvent ( "createHouse", true ) function createHouses () x, y, z = unpackRobberHouses () local rob = getElementModel ( localPlayer ) if ( rob == 29 ) then robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) end end addEventHandler ( "createHouse", root, createHouses ) addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then triggerServerEvent ( "payPlayer", localPlayer ) destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) triggerEvent ( "createHouse", localPlayer ) end end ) Link to comment
damien111 Posted January 5, 2013 Author Share Posted January 5, 2013 addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) local rob = getElementModel ( localPlayer ) if ( rob == 29 ) then triggerEvent ( "createHouse", localPlayer ) end end ) I just tryed this, didnt work, any other ideas? Link to comment
damien111 Posted January 5, 2013 Author Share Posted January 5, 2013 local robberHouses = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} -- Messi Put coord In This Table pl0x } function unpackRobberHouses () return unpack ( robberHouses [ math.random ( #robberHouses ) ] ) end addEvent ( "createHouse", true ) function createHouses () x, y, z = unpackRobberHouses () local rob = getElementModel ( localPlayer ) if ( rob == 29 ) then robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) end end addEventHandler ( "createHouse", root, createHouses ) addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then triggerServerEvent ( "payPlayer", localPlayer ) destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) triggerEvent ( "createHouse", localPlayer ) end end ) Not Working Either Mate. Link to comment
damien111 Posted January 5, 2013 Author Share Posted January 5, 2013 /debugscript 3 please. There were none Link to comment
damien111 Posted January 5, 2013 Author Share Posted January 5, 2013 <meta> <info author="Damien" description="Robber Job" version="1" type="misc"/> <script src="RobberC.lua" type="client"/> <script src="RobberS.lua" type="server"/> </meta> Link to comment
Baseplate Posted January 5, 2013 Share Posted January 5, 2013 And how it's not working? Like, which part does the script fails at? Link to comment
Vision Posted January 5, 2013 Share Posted January 5, 2013 Server addEvent ( "payPlayer", true ) function givePlayerRobPay () money = math.random ( 350, 1020 ) givePlayerMoney ( source, money ) outputChatBox ( "You succesfully robbed $" ..money, source ) end addEventHandler ( "payPlayer", root, givePlayerRobPay ) Client local robberHouses = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} -- Messi Put coord In This Table pl0x } function unpackRobberHouses () return unpack ( robberHouses [ math.random ( #robberHouses ) ] ) end addEvent ( "createHouse", true ) function createHouses () x, y, z = unpackRobberHouses () local rob = getElementModel ( localPlayer ) if ( rob == 29 ) then robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) end end addEventHandler ( "createHouse", root, createHouses ) addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) local rob = getElementModel ( localPlayer ) if ( rob == 29 ) then triggerEvent ( "createHouse", localPlayer ) end end ) addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then triggerServerEvent ( "payPlayer", localPlayer ) destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) triggerEvent ( "createHouse", localPlayer ) end end ) Link to comment
damien111 Posted January 5, 2013 Author Share Posted January 5, 2013 it doesnt create the house marker Link to comment
TAPL Posted January 5, 2013 Share Posted January 5, 2013 Change this: robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) To: robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32 ) Link to comment
damien111 Posted January 5, 2013 Author Share Posted January 5, 2013 That would help , but the marker isnt being created, i dont think, i still applied it though, and tested Link to comment
damien111 Posted January 6, 2013 Author Share Posted January 6, 2013 any other ideas? Link to comment
TAPL Posted January 6, 2013 Share Posted January 6, 2013 local robberHouses = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} } function unpackRobberHouses() return unpack(robberHouses[math.random(#robberHouses)]) end addEvent("createHouse", true) function createHouses() local rob = getElementModel(localPlayer) if (rob == 29) and not isElement(robhouseMarker) then local x, y, z = unpackRobberHouses() robhouseMarker = createMarker(x, y, z, "cylinder", 3, 255, 51, 102, 85) robhouseBlip = createBlipAttachedTo(robhouseMarker, 32) elseif (rob ~= 29) and isElement(robhouseMarker) then destroyElement(robhouseMarker) destroyElement(robhouseBlip) end end addEventHandler("createHouse", root, createHouses) addEventHandler("onClientResourceStart", resourceRoot, function() setTimer(function() triggerEvent("createHouse", localPlayer) end, 5000, 0) end) addEventHandler("onClientMarkerHit", root, function(hitElement) if (source == robhouseMarker and hitElement == localPlayer and not isPedInVehicle(hitElement)) then triggerServerEvent("payPlayer", hitElement) if isElement(robhouseMarker) then destroyElement(robhouseMarker) end if isElement(robhouseBlip) then destroyElement(robhouseBlip) end 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