Jump to content

Create a random marker.


Gtagasje

Recommended Posts

Posted

Hi,

I wanna create a one of the given markers if you enter a vehicle, and if you are on the team "Criminal".

I tried this script [i made it server side]:

  
local criminal = createTeam("Criminal", 255, 0, 0) 
  
function createAmarker () 
    if getPlayerTeam(getTeamFromName(criminal)) then 
    theMarkers = { 
    createMarker (0, 0, 20), 
    createMarker (1, 0, 20), 
    createMarker (2, 0, 20), 
    createMarker (3, 0, 20) } 
    markersTable[math.random(#theMarkers)] 
    end 
end 
addEventHandler("onVehicleEnter", getRootElement(), createAmarker) 
  

but it shows this error: "SCRIPT ERROR: :line 11: '=' expected near end."

I don't know how to fix this, I tried a lot of things, but I wasn't able to fix this.

Once again in short, I wan't the script to create one of the markers in the script, if the player (on criminal team) enters a vehicle. But it shows that error, which i'm not able to fix.

Regards,

Gtagasje

Yes, this is infact a signature.

Posted

well, it can be done like this

  
local criminal = createTeam("Criminal", 255, 0, 0) 
     function randomMarker() 
        randomNum = math.random(1,4) 
        if randomNum == 1 then 
        createMarker (0, 0, 20) 
        elseif randomNum == 2 then 
        createMarker (1, 0, 20) 
        elseif randomNum == 3 then 
        createMarker (2, 0, 20) 
        elseif randomNum == 4 then 
        createMarker (3, 0, 20) 
        end 
    end 
function createAmarker (plr) 
    if getPlayerTeam(plr) == getTeamFromName("Criminal") then 
    randomMarker() 
    end 
end 
addEventHandler("onVehicleEnter", getRootElement(), createAmarker) 
  

ING : [xXx]~Al3grab

Posted

Try this:

local criminal = createTeam("Criminal", 255, 0, 0) 
  
function createAmarker () 
    if getPlayerTeam(getTeamFromName(criminal)) then 
    local theMarkers = { 
    createMarker (0, 0, 20), 
    createMarker (1, 0, 20), 
    createMarker (2, 0, 20), 
    createMarker (3, 0, 20) } 
    markersTable[math.random(#theMarkers)] 
    end 
end 
addEventHandler("onVehicleEnter", getRootElement(), createAmarker) 
  

You need 'local' before theMarkers.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted
local criminal = createTeam("Criminal", 255, 0, 0) 
local positions = { 
    {0, 0, 20}, 
    {1, 0, 20}, 
    {2, 0, 20}, 
    {3, 0, 20}, 
} 
  
function createAmarker (thePlayer) 
    if ( getPlayerTeam(thePlayer) and getPlayerTeam(thePlayer) == criminal ) then 
        local x, y,z = unpack(positions[math.random(#positions)]) 
        createMarker(x, y, z) 
    end 
end 
addEventHandler("onVehicleEnter", getRootElement(), createAmarker) 

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

Solidsnake14, was not necessary to you reply. I have already answered and Gtagasje had achieved ...

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

We can say... two options is better than one?

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

Why Gtagasje need two options if only one is needed ?

Ok, no problem, I don't want to "fight" in the forum ...

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

Who knows? maybe someone ELSE has the same problem and want's to do it in a different way, nobody know's.

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.

  • 3 years later...
Posted
Who knows? maybe someone ELSE has the same problem and want's to do it in a different way, nobody know's.

Thanks man <3

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