Jump to content

Any pro will help with my scipts?


jingzhi

Recommended Posts

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
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
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
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

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
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

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
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
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
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 by Guest
Link to comment
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...