Advertisement
Guest User

Untitled

a guest
Jul 12th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. ---------------
  2. -- Client.
  3. ---------------
  4. RegisterNetEvent('resource:spawnPed')
  5. AddEventHandler('resource:spawnPed', function(ped)
  6. local pedhash = GetHashKey(ped)
  7. RequestModel(pedhash)
  8. repeat
  9. Citizen.Wait(10)
  10. until HasModelLoaded(pedhash)
  11. SetPlayerModel(PlayerId(), pedhash)
  12. -- Notification / Chat Message / Whatever.
  13. end)
  14.  
  15. ---------------
  16. -- Server.
  17. ---------------
  18. local authList = {
  19. 'steam:id'
  20. }
  21.  
  22. -- iirc GetPlayerIdentifiers won't return a steam id if they don't have steam running (gta5 not bought thru steam for example).
  23. -- This should be license keys instead since EVERYONE has one (and it's always present) and not every server requires steam to be running to connect.
  24. local function getIdentifier(type, id)
  25. local identifiers = {}
  26. local numIdentifiers = GetNumPlayerIdentifiers(id)
  27. for i = 0, numIdentifiers do
  28. table.insert(identifiers, GetPlayerIdentifier(id, i))
  29. end
  30. for i = 1, #identifiers do
  31. if string.find(identifiers[i], type, 1) then
  32. return identifiers[i]
  33. end
  34. end
  35. return false
  36. end
  37.  
  38. RegisterCommand('setped', function(source, args)
  39. local src = source
  40. if args[1] == nil then
  41. -- Ped arg not present.
  42. return
  43. end
  44. local id = getIdentifier('steam', src)
  45. if not id then
  46. -- Chat message or whatever.
  47. return -- Stop the code from continuing.
  48. end
  49. for i = 1, #authList do
  50. if authList[i] == id then
  51. TriggerClientEvent('resource:spawnPed', src, args[1])
  52. return -- Exit the loop.
  53. end
  54. end
  55. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement