jingzhi Posted February 5, 2015 Share Posted February 5, 2015 I was trying to make a script for when player go into the marker and it spawns a bike and put the player on the bike at the same time. So i made this script but its not working, when i step into marker, nothing happens, debugscript mode 3 shows nothing. Here is my script : marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1,255,255,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then local Vehicle = createVehicle (509,1514.20679,-1657.22742,12.5) warpPedIntoVehicle (thePlayer, Vehicle) end end) Link to comment
WASSIm. Posted February 5, 2015 Share Posted February 5, 2015 client or server side ? Link to comment
jingzhi Posted February 5, 2015 Author Share Posted February 5, 2015 client or server side ? its server side, and by the way, i found out its only working while you are in a vehicle, then you will be put on a bike Link to comment
-.Paradox.- Posted February 5, 2015 Share Posted February 5, 2015 marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1,255,255,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then local x,y,z = getElementPosition(thePlayer) local veh = createVehicle (509,x,y,z) warpPedIntoVehicle (thePlayer, veh) end end) Link to comment
jingzhi Posted February 5, 2015 Author Share Posted February 5, 2015 marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1,255,255,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then local x,y,z = getElementPosition(thePlayer) local veh = createVehicle (509,x,y,z) warpPedIntoVehicle (thePlayer, veh) end end) Thank you! and can you tell me the reason you change "Vehicle" to "veh"? Link to comment
jingzhi Posted February 5, 2015 Author Share Posted February 5, 2015 marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1,255,255,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then local x,y,z = getElementPosition(thePlayer) local veh = createVehicle (509,x,y,z) warpPedIntoVehicle (thePlayer, veh) end end) I have just tested it and it got the same problem with the original Link to comment
manawydan Posted February 6, 2015 Share Posted February 6, 2015 try this local marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1,255,255,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then local x,y,z = getElementPosition(thePlayer) local veh = createVehicle (509,x,y,z) setTimer(warpPedIntoVehicle,100,1,thePlayer,veh) end end) Link to comment
jingzhi Posted February 6, 2015 Author Share Posted February 6, 2015 try this local marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1,255,255,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then local x,y,z = getElementPosition(thePlayer) local veh = createVehicle (509,x,y,z) setTimer(warpPedIntoVehicle,100,1,thePlayer,veh) end end) I Will try later when I get home, but I wonder how could a timer help Link to comment
Mega9 Posted February 6, 2015 Share Posted February 6, 2015 Sometimes it gets executed too fast so it does not warp you in the vehicle, setting a small delay used to fix this problem. Link to comment
Ryancit2 Posted February 6, 2015 Share Posted February 6, 2015 Its not about the delay, neither is related to client/server side, check this: local marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1.2,255,255,255) function MarkerHit(plr) if getElementType(plr) == "player" then if (isPedInVehicle(plr)) then return end local x, y, z = getElementPosition(plr) local veh = createVehicle(509, x, y, z) warpPedIntoVehicle(plr, veh) end end addEventHandler("onMarkerHit", marker, MarkerHit) Marker size was 1, which made marker's actual size start from slightly lower than ground level by which it didn't detected hitElement. I changed the size to 1.2 + added exception if Player is already in vehicle, function wont proceed. Link to comment
jingzhi Posted February 6, 2015 Author Share Posted February 6, 2015 Its not about the delay, neither is related to client/server side, check this: local marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1.2,255,255,255) function MarkerHit(plr) if getElementType(plr) == "player" then if (isPedInVehicle(plr)) then return end local x, y, z = getElementPosition(plr) local veh = createVehicle(509, x, y, z) warpPedIntoVehicle(plr, veh) end end addEventHandler("onMarkerHit", marker, MarkerHit) Marker size was 1, which made marker's actual size start from slightly lower than ground level by which it didn't detected hitElement. I changed the size to 1.2 + added exception if Player is already in vehicle, function wont proceed. Thank you very much, but will it also fix the problem that it won't put me on a bike when I'm on foot? I will your scripts as soon as I get home. Link to comment
Ryancit2 Posted February 6, 2015 Share Posted February 6, 2015 When you are "NOT"* on foot? edit line#5 with this: if (isPedInVehicle(plr)) or (not isPedOnGround(plr)) or (doesPedHaveJetPack(plr)) then return end Link to comment
jingzhi Posted February 6, 2015 Author Share Posted February 6, 2015 When you are "NOT"* on foot? edit line#5 with this: if (isPedInVehicle(plr)) or (not isPedOnGround(plr)) or (doesPedHaveJetPack(plr)) then return end The original problem is, when I'm on foot, it won't put me on a bike, it only will if I'm in a vehicle Link to comment
Ryancit2 Posted February 6, 2015 Share Posted February 6, 2015 When you are "NOT"* on foot? edit line#5 with this: if (isPedInVehicle(plr)) or (not isPedOnGround(plr)) or (doesPedHaveJetPack(plr)) then return end The original problem is, when I'm on foot, it won't put me on a bike, it only will if I'm in a vehicle Change Line#5 with this: if (not isPedInVehicle(plr)) then return end Link to comment
-.Paradox.- Posted February 6, 2015 Share Posted February 6, 2015 Try /debugscript 3 or debug it with outputChatBox to see what's wrong Link to comment
jingzhi Posted February 6, 2015 Author Share Posted February 6, 2015 (edited) When you are "NOT"* on foot? edit line#5 with this: if (isPedInVehicle(plr)) or (not isPedOnGround(plr)) or (doesPedHaveJetPack(plr)) then return end The original problem is, when I'm on foot, it won't put me on a bike, it only will if I'm in a vehicle Change Line#5 with this: if (not isPedInVehicle(plr)) then return end But I want the function to be : It put me on a bike if I'm on foot, but it won't if I'm in a vehicle. I'm not sure if I have explained it clear enough, anyways, I will try those as soon as I get home Edited February 6, 2015 by Guest Link to comment
jingzhi Posted February 6, 2015 Author Share Posted February 6, 2015 Try /debugscript 3 or debug it with outputChatBox to see what's wrong Debug script 3 doesn't show any thing, but it just doesn't work unless I'm in a vehicle Link to comment
Ryancit2 Posted February 6, 2015 Share Posted February 6, 2015 Try /debugscript 3 or debug it with outputChatBox to see what's wrong Debug body wont show up any message because script didn't had any 'bug'. But I want the function to be : It put me on a bike if I'm on foot, but it won't if I'm in a vehicle. I'm not sure if I have explained it clear enough, anyways, I will try those as soon as I get home Yea thats what i gave you at very first reply on mine here, but then again you mis-explained it or i misunderstood it, anyways, here is what you want: local marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1.2,255,255,255) function MarkerHit(plr) if getElementType(plr) == "player" then if (isPedInVehicle(plr)) then return end local x, y, z = getElementPosition(plr) local veh = createVehicle(509, x, y, z) warpPedIntoVehicle(plr, veh) end end addEventHandler("onMarkerHit", marker, MarkerHit) \ This wont spawn vehicle if you are already in a vehicle. Link to comment
jingzhi Posted February 6, 2015 Author Share Posted February 6, 2015 Try /debugscript 3 or debug it with outputChatBox to see what's wrong Debug body wont show up any message because script didn't had any 'bug'. But I want the function to be : It put me on a bike if I'm on foot, but it won't if I'm in a vehicle. I'm not sure if I have explained it clear enough, anyways, I will try those as soon as I get home Yea thats what i gave you at very first reply on mine here, but then again you mis-explained it or i misunderstood it, anyways, here is what you want: local marker = createMarker(1514.20679,-1657.22742,12.5,"cylinder",1.2,255,255,255) function MarkerHit(plr) if getElementType(plr) == "player" then if (isPedInVehicle(plr)) then return end local x, y, z = getElementPosition(plr) local veh = createVehicle(509, x, y, z) warpPedIntoVehicle(plr, veh) end end addEventHandler("onMarkerHit", marker, MarkerHit) \ This wont spawn vehicle if you are already in a vehicle. Thanks a lot I have tried it, now it works Link to comment
-.Paradox.- Posted February 6, 2015 Share Posted February 6, 2015 Try /debugscript 3 or debug it with outputChatBox to see what's wrong Debug body wont show up any message because script didn't had any 'bug'. Read my whole reply. Try /debugscript 3 or debug it with outputChatBox to see what's wrong Its oversized, in case you can't see it. Link to comment
Ryancit2 Posted February 7, 2015 Share Posted February 7, 2015 A guy is facing a bug on such trivial thing as "MARKER SIZE" how would he even understand what "DEBUG WITH CHATBOX" is? Also, problem is solved so excuse me @Paradox. Link to comment
vx89 Posted February 7, 2015 Share Posted February 7, 2015 Also check what warpPedIntoVehicle returns (true or false) Link to comment
-.Paradox.- Posted February 7, 2015 Share Posted February 7, 2015 A guy is facing a bug on such trivial thing as "MARKER SIZE" how would he even understand what "DEBUG WITH CHATBOX" is? Also, problem is solved so excuse me @Paradox. There. Also check what warpPedIntoVehicle returns (true or false) 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