[Release] Roll Windows

So I made a simple script which is pretty self explanatory,
if you type /rollw
the driver and passenger windows roll down, type it again, and they go up!

_resource.lua

-- RollWindows written by JAF
-- Made for www.lacountyrp.com
-- Version 1.0.0

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'    --(Thank you @Vespura)

-- Add a client script 
client_script 'client.lua'

client.lua

local windowup = true
RegisterNetEvent("RollWindow")
AddEventHandler('RollWindow', function()
    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
				RollDownWindow(playerCar, 0)
				RollDownWindow(playerCar, 1)
				TriggerEvent('chatMessage', '', {255,0,0}, 'Windows down')
				windowup = false
			else
				RollUpWindow(playerCar, 0)
				RollUpWindow(playerCar, 1)
				TriggerEvent('chatMessage', '', {255,0,0}, 'Windows up')
				windowup = true
			end
		end
	end
end )

RegisterCommand("rollw", function(source, args, raw)
    TriggerEvent("RollWindow")
end, false) --False, allow everyone to run it(thnx @Havoc)

Enjoy! More scripts are coming!

5 Likes

You know you can make this thing entirely client-side right? Just remove the “chatMessage” handler on the server and use the RegisterCommand native on the client.

Also, it’s bad practice to have no manifest version for the resource. You should at least use 77731fab-63ca-442c-a67b-abc70f28dfa5.

http://docs.fivem.net/resources/manifest-versions/

had no idea what is does, remove it, script still works. What does that actually do?

Also i don’t think many people care. They just want the script to work, but thanks, I’ll keep that in mind for later

Talking about the RegisterCommand or the resource manifest?


Resource Manifest info

http://docs.fivem.net/resources/manifest/

…and…


Register Command Reference
http://runtime.fivem.net/doc/reference.html#_0x5fa79b0f

I used the register command like on my other scripts, but didn’t seem to work, so i did it server sided,
thanks for answer tho

Well, sorry to say, you used it wrong.

RegisterCommand("rollw", function(source, args, raw)
    TriggerEvent("RollWindow")
end, false) --False, allow everyone to run it

Oh okay. i probably did,
I only started scripting a couple of weeks ago :confused:

1 Like

Not sure if someone can help, the mod works great clientside, but serverside the windows will go down but not up. any ideas?

I will check that. Didnt realize this.

Thank you, please keep me informed.

Is there a download? Or do we just make a folder in resources called rollw and make the client script?

Works just like any other resource.

Did you check out the server side roll up not working? only shows for the client that does the action.

@callmejaf my rollw folder wont load

PIC
https://gyazo.com/2527d8fe5bf6f086c690a7d38e55b221
https://gyazo.com/24cb28e9aff71fd7aa2ccf6831efaa6f/draw
https://gyazo.com/26c9260b2ac2d1be881138e60228bc47
https://gyazo.com/5b96b824b4d7a0bec0e20c97e5f01ef4

1 Like

Load resource in server.cfg.

if you wanted windows to go up and down with the arrow keys (172, 173) how would you go about that can anyone help?

This is the editied version of this script. All i did is removing the print in chat as it’s annoying and i added a toggle for arrow down. So press once windows are down then press again and they are upclient.lua (808 Bytes) replace client.lua with the one i provided

1 Like

thanks a lot @XxFri3ndlyxX ill give it a go

@XxFri3ndlyxX keeps failing to load any ideas?