I’ve spent a good amount of time tinkering with this tonight, and perusing the forums. I’ve gotten as far as I have based on the information I’ve been able to identify on my own. I am, however, not getting expected results and would like to see if anyone could point out what simple mistake I am making.
My test case is a very visible Window Toggle in Vehicles. No arguments will roll down/up all windows, and the intention is for a provided argument to roll down the appropriate window 0, 1, 2, or 3. I haven’t even dove into displaying in the help what the appropriate arguments are and I hope to do this next, but first I need this to function. Any argument will toggle window 0 only right now… it doesn’t matter what number is provided. I suspect this is related to chat being a string and not an int, but I’m about to sign off for the night and won’t approach again until tomorrow.
Server
RegisterCommand('rw', function(source, args, raw)
if args ~= nil then
TriggerClientEvent('rollwindow', source, args[1])
else
TriggerClientEvent('rollwindow', source)
end
end, false)
Client
local windowup = true
RegisterNetEvent('rollwindow')
AddEventHandler('rollwindow', function(args)
local playerPed = GetPlayerPed(-1)
if IsPedInAnyVehicle(playerPed, false) then
local playerCar = GetVehiclePedIsIn(playerPed, false)
if ( GetPedInVehicleSeat( playerCar, -1 ) == playerPed ) then
SetEntityAsMissionEntity( playerCar, true, true )
if ( windowup ) then
if args ~= nil then
RollDownWindow(playerCar, args[1])
else
RollDownWindows(playerCar)
end
--TriggerEvent('chatMessage', '', {255,0,0}, 'Windows down')
windowup = false
else
if args ~= nil then
RollUpWindow(playerCar, args[1])
else
RollUpWindow(playerCar, 0)
RollUpWindow(playerCar, 1)
RollUpWindow(playerCar, 2)
RollUpWindow(playerCar, 3)
end
--TriggerEvent('chatMessage', '', {255,0,0}, 'Windows up')
windowup = true
end
end
end
end)
When I printed the args[1] to chat it output {0}{1} but not value. I am certain I simply haven’t looked deeply into harvesting the integer value from this, but I figured I’d post this before going to bed in case another restless scripter would be willing to share their insight.
I appreciate anyone that assists.