Jump to content

Somekinda error...


Bleidex

Recommended Posts

Posted

function MapStarting(mapInfo, mapOptions, gameOptions) 
    for id, player in ipairs(getElementsByType("player")) do 
        local playerAccount = getPlayerAccount ( player ) 
        local playerPlayedMaps = getAccountData ( playerAccount, "MapsPlayed" ) or 0 
        local playerTeam = getPlayerTeam ( player ) 
        local playerVehicle = GetPlayerOccupiedVehicle ( player ) 
        setAccountData ( playerAccount, "MapsPlayed", tonumber(playerPlayedMaps) + 1 ) 
        if playerTeam == "Red" then 
            setVehicleColor ( playerVehicle, 3, 3, 3, 3 ) 
        elseif playerTeam == "Blue" then 
            setVehicleColor ( playerVehicle, 7, 7, 7, 7 ) 
        end 
    end 
end 
addEventHandler ( "onMapStarting", getRootElement(), MapStarting ) 

script fails getting player vehicle, but i dont know how to make it that it would get player vehicle and would set its color on map start

Posted

its

getPedOccupiedVehicle() 

not

GetPlayerOccupiedVehicle() 

as you see, 2 errors, ped, not player, and caps at 1st letter

also use

 tags, if you would use them, you would find the error yourself.
Posted

Doesnt output any errors now, but it still doesnt set vehicle color. Tested on Infernus and Sandking. Maybe I use that funcion not how it should be?

Posted
also use
 tags, if you would use them, you would find the error yourself.

Lua highlighter breaks the code on certain functions (get/setPlayerTeam for example), dunno if it will ever be fixed.

Posted
also use
 tags, if you would use them, you would find the error yourself.

Lua highlighter breaks the code on certain functions (get/setPlayerTeam for example), dunno if it will ever be fixed.

i was aware of setPlayerTeam only.

is the a report in forum maintance section?

Posted

Everything is ok now, but it gets stuck on setVehicleColor - bad argument... I don't know how i shoudl change it

function MapStarting(mapInfo, mapOptions, gameOptions) 
    for id, player in ipairs(getElementsByType("player")) do 
        local playerAccount = getPlayerAccount ( player ) 
        local playerPlayedMaps = getAccountData ( playerAccount, "MapsPlayed" ) or 0 
        local playerTeam = getTeamName ( getPlayerTeam ( player ) ) 
        local playerVehicle = getPedOccupiedVehicle ( player ) 
        setAccountData ( playerAccount, "MapsPlayed", tonumber(playerPlayedMaps) + 1 ) 
        if playerTeam == "Red" then 
            setVehicleColor ( playerVehicle, 3, 3, 3, 3 ) 
        elseif playerTeam == "Blue" then 
            setVehicleColor ( playerVehicle, 7, 7, 7, 7 ) 
        end 
    end 
end 
addEventHandler ( "onMapStarting", getRootElement(), MapStarting ) 

Posted

you should always check if player is in a vehicle, before doing anything with the (supposedly) vehicle element.

even in race mode player can be not in a vehicle at all.

function MapStarting(mapInfo, mapOptions, gameOptions) 
    for id, player in ipairs(getElementsByType("player")) do 
        local playerAccount = getPlayerAccount ( player ) 
        local playerPlayedMaps = getAccountData ( playerAccount, "MapsPlayed" ) or 0 
        local playerTeam = getTeamName ( getPlayerTeam ( player ) ) 
        local playerVehicle = getPedOccupiedVehicle ( player ) 
        setAccountData ( playerAccount, "MapsPlayed", tonumber(playerPlayedMaps) + 1 ) 
        if playerVehicle and playerTeam == "Red" then 
            setVehicleColor ( playerVehicle, 3, 3, 3, 3 ) 
        elseif playerVehicle and playerTeam == "Blue" then 
            setVehicleColor ( playerVehicle, 7, 7, 7, 7 ) 
        end 
    end 
end 
addEventHandler ( "onMapStarting", getRootElement(), MapStarting ) 

Posted

Doesnt output any errors now, but it still doesnt work - sets random vehicle color (tested on vehicles that can have custom colors)

Posted

All players aren't in vehicles on map start.

Just use onPlayerVehicleEnter function. And isGuestAccount() check wouldn't hurt either.

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