Jump to content

Marker Vechile Spawner.


damien111

Recommended Posts

Posted

I am a few days into scripting! I need help with this, i know its simple but im not sure why this isnt working. it doesnt even spawn a marker. heres the code. i only have a client side file.

local VehMarker createMarker (2158, 2449, 11, "Cylinder", 2, 0, 0, 255, 153) 
  
function spawnveh(hitElement, matchingDimension) 
  
pteam = getPlayerTeam (source) 
if pteam = "Police" then 
  
local elementType = getElementType( hitElement) 
        local x, y, z = getElementPosition(thePlayer) 
        local vehicle = createVehicle(tonumber(597), x, y, z) 
end 
end 
addEventHandler ( "onMarkerHit", VehMarker, spawnveh ) 

Posted

It has many errors.

local VehMarker createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) 
  
function spawnveh ( hitElement, matchingDimension ) 
    local elementType = getElementType ( hitElement ) 
    if ( elementType == "player" ) then 
        local pteam = getPlayerTeam ( hitElement ) 
        local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) 
        if ( pTeamName = "Police" ) then 
            local x, y, z = getElementPosition ( hitElement ) 
            local vehicle = createVehicle ( 597, x, y, z ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", VehMarker, spawnveh ) 

That should work.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

P.S: We all learn from trial & error.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

lol

this

local VehMarker createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) 

should be

local VehMarker = createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) 

CiTLh.png
Posted

And:

if ( elementType ) then 

Should be:

if ( elementType == "player" ) then 

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

i fixed up the code but still no marker is being created:

  
    local VehMarker = createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) 
      
    function spawnveh ( hitElement, matchingDimension ) 
        local elementType = getElementType ( hitElement ) 
    if ( elementType == "player" ) then 
            local pteam = getPlayerTeam ( hitElement ) 
            local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) 
            if ( pTeamName = "Police" ) then 
                local x, y, z = getElementPosition ( hitElement ) 
                local vehicle = createVehicle ( 597, x, y, z ) 
            end 
        end 
    end 
    addEventHandler ( "onMarkerHit", VehMarker, spawnveh ) 
  

Posted
i fixed up the code but still no marker is being created:
  
    local VehMarker = createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) 
      
    function spawnveh ( hitElement, matchingDimension ) 
        local elementType = getElementType ( hitElement ) 
    if ( elementType == "player" ) then 
            local pteam = getPlayerTeam ( hitElement ) 
            local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) 
            if ( pTeamName = "Police" ) then 
                local x, y, z = getElementPosition ( hitElement ) 
                local vehicle = createVehicle ( 597, x, y, z ) 
            end 
        end 
    end 
    addEventHandler ( "onMarkerHit", VehMarker, spawnveh ) 
  

You didn't fix this one

line 8
if ( pTeamName = "Police" ) then 

should be

if ( pTeamName == "Police" ) then 

CiTLh.png
Posted

It must be server-side.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
And:
if ( elementType ) then 

Should be:

if ( elementType == "player" ) then 

Oh, my bad, I forgot about that part.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
so has anyone figured out what the prob was? :S i need to know why it isnt making the marker :P ill try making it serverside :S

The code is server-side as I said, but you added it as client in the meta.xml

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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