Created
July 9, 2017 18:29
-
-
Save DATADEER/df4f58d07ea6ba31a93558f3a366acaa to your computer and use it in GitHub Desktop.
[FiveM Server] Get random loadout on respawn (REQUIRE LOADOUTS DOES NOT WORK)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client_script 'loadouts.lua' | |
| client_script 'preconditions.lua' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local loadouts = { | |
| { | |
| weapon = "WEAPON_SNOWBALL" | |
| }, | |
| { | |
| weapon = "WEAPON_MUSKET" | |
| }, | |
| { | |
| weapons = "WEAPON_BOTTLE" | |
| } | |
| } | |
| return loadouts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local loadouts = require("loadouts") | |
| function randomLoadout(loadouts) | |
| local randomLoadoutIndex = math.random(#loadouts) | |
| return loadouts[randomLoadoutIndex] | |
| end | |
| AddEventHandler('playerSpawned', function(spawn) | |
| local player = GetPlayerPed(-1) | |
| local randomLoadout = randomLoadout(loadouts) | |
| local randomWeapon = GetHashKey(randomLoadout.weapon) | |
| sendMessage("You spawned with " .. randomLoadout.weapon) | |
| GiveWeaponToPed(player, randomWeapon, 60, false) | |
| end) | |
| function sendMessage(message) | |
| TriggerEvent('chatMessage', '', { 0, 0, 0 }, message) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment