Created
September 29, 2018 15:57
-
-
Save DemmyDemon/63db0eab32720d89fdd3acc2a99ca42a to your computer and use it in GitHub Desktop.
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
| if IsDuplicityVersion() then | |
| local PICKUP_ID = math.abs(GetHashKey(GetCurrentResourceName())+math.random(-15000,15000)) | |
| local PICKUP_CALLBACKS = {} | |
| function pRegisterPickup(player,x,y,z,modelHash,callback) | |
| TriggerClientEvent(GetCurrentResourceName()..':make-registered-pickup',player,x,y,z,PICKUP_ID,modelHash) | |
| log(type(callback),'stored as',PICKUP_ID) | |
| PICKUP_CALLBACKS[PICKUP_ID] = callback | |
| PICKUP_ID = PICKUP_ID + 1 | |
| end | |
| RegisterNetEvent(GetCurrentResourceName()..':picked-up') | |
| AddEventHandler (GetCurrentResourceName()..':picked-up',function(id) | |
| log('pickup triggered:',id) | |
| if PICKUP_CALLBACKS[id] then | |
| log('has callback') | |
| PICKUP_CALLBACKS[id](source) | |
| PICKUP_CALLBACKS[id] = nil | |
| else | |
| log('no callback') | |
| end | |
| end) | |
| RegisterCommand('cashpile',function(source,args,raw) | |
| if source ~= 0 then | |
| pRegisterPickup(source,215.676,-863.194,30.452,GetHashKey('prop_cash_pile_02'),function(player) | |
| log(paradiseLogIdentity(player),'picked up $1000 (just kidding!)') | |
| TriggerClientEvent('paradiseui:pushtext',player,'Pretend you got $1000') | |
| end) | |
| else | |
| log('Only works in-game. Sorry') | |
| end | |
| end,true) | |
| else | |
| RegisterNetEvent(GetCurrentResourceName()..':make-registered-pickup') | |
| AddEventHandler (GetCurrentResourceName()..':make-registered-pickup',function(x,y,z,id,modelHash) | |
| Citizen.CreateThread(function() | |
| if not IsModelValid(modelHash) then | |
| modelHash = GetHashKey('prop_poolball_8') | |
| end | |
| if not HasModelLoaded(modelHash) then | |
| RequestModel(modelHash) | |
| end | |
| while not HasModelLoaded(modelHash) do | |
| Citizen.Wait(0) | |
| end | |
| local safeLocation = GetSafePickupCoords(vector3(x,y,z),0.0,5.0) | |
| --serverlog('Creating pickup',id,'at',x,y,z,'with model',model,'('..modelHash..')') | |
| local pickup = CreateAmbientPickup( | |
| 738282662, -- GetHashKey('PICKUP_CUSTOM_SCRIPT') | |
| safeLocation, | |
| 0, -- Rotation!? | |
| id, | |
| modelHash, | |
| true, | |
| true | |
| ) | |
| --FreezeEntityPosition(pickup,true) | |
| DecorSetBool(pickup,'ParadisePickup',true) | |
| SetModelAsNoLongerNeeded(modelHash) | |
| end) | |
| end) | |
| AddEventHandler('gameEventTriggered',function(name,args) | |
| if name == 'CEventNetworkPlayerCollectedAmbientPickup' then | |
| if args[1] == 738282662 then -- GetHashKey('PICKUP_CUSTOM_SCRIPT') | |
| serverlog('Pickup!') | |
| TriggerServerEvent(GetCurrentResourceName()..':picked-up',args[2]) | |
| end | |
| end | |
| end) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment