Jump to content

Police light


albers14

Recommended Posts

Hey all I tried to make this script for outputting all the information about all siren points at my vehicle but unsuccesfull

  
function getSirens(thePlayer) 
if thePlayer and isPedInVehicle(thePlayer) then 
sirenData = getVehicleSirens(getPedOccupiedVehicle(thePlayer)) 
parm = getVehicleSirenParams(getPedOccupiedVehicle(thePlayer)) 
int = parm.SirenCount 
for i = 1,int do 
  
outputChatBox("setVehicleSirens(getPedOccupiedVehicle(thePlayer),"..i..","..tostring(sirenData[i][4])..","..tostring(sirenData[i][5])..","..tostring(sirenData[i][6])..","..tostring(sirenData[i][1])..","..tostring(sirenData[i][2])..","..tostring(sirenData[i][3])..")") 
end 
end 
end 
addCommandHandler("specs", getSirens) 
  
  
  
  

The outputchatbox 6 last arguments outputs nil where they should give me a number. Any solution? The for i = 1, int do works fine as it outputs the number find :)

Link to comment
  
function getSirens(thePlayer) 
    if thePlayer and isPedInVehicle(thePlayer) then 
        sirenData = getVehicleSirens(getPedOccupiedVehicle(thePlayer)) 
        for i,siren in ipairs(sirenData) do 
            outputChatBox("setVehicleSirens(getPedOccupiedVehicle(thePlayer),"..i..","..tostring(siren[4])..","..tostring(siren[5])..","..tostring(siren[6])..","..tostring(siren[1])..","..tostring(siren[2])..","..tostring(siren[3])..")") 
        end 
    end 
end 
addCommandHandler("specs", getSirens) 
  

Edited by Guest
Link to comment

try this:

addCommandHandler("specs",function(thePlayer) 
    if not isPedInVehicle(thePlayer)then return end 
    local pVeh = getPedOccupiedVehicle(thePlayer) 
    local sirenData = getVehicleSirens(pVeh) 
    local parm = getVehicleSirenParams(pVeh) 
    if not sirenData or not parm then return end 
    local int = parm.SirenCount 
    for i = 0,int do 
        outputChatBox("setVehicleSirens(getPedOccupiedVehicle(thePlayer),"..i..","..tostring(sirenData[i][4])..","..tostring(sirenData[i][5])..","..tostring(sirenData[i][6])..","..tostring(sirenData[i][1])..","..tostring(sirenData[i][2])..","..tostring(sirenData[i][3])..")") 
    end 
end) 

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