Advertisement
SEnergy

Untitled

Sep 13th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. RegisterNetEvent("character:spawn");
  2. AddEventHandler("character:spawn", function(model, position)
  3.     if not model or not position or not position.x or not position.y or not position.z then
  4.         Citizen.Trace("This event requires character's model and position information!");
  5.         return;
  6.     end;
  7.    
  8.     DoScreenFadeOut(1500);
  9.     while IsScreenFadingOut() do Citizen.Wait(0) end;
  10.    
  11.     -- load & change model
  12.     local ready = false;
  13.     TriggerEvent("model:change", model, CallbackAdd(function() ready = true; end));
  14.    
  15.     -- wait for model change confirm
  16.     while not ready do Citizen.Wait(0) end;
  17.    
  18.     -- spawn player ped on selected position
  19.     local ped = PlayerPedId();
  20.     position.z = position.z + 0.25;
  21.    
  22.     RequestCollisionAtCoord(position.x, position.y, position.z);
  23.     NetworkResurrectLocalPlayer(position.x, position.y, position.z, 0.0, true, true, false);
  24.     SetEntityCoordsNoOffset(ped, position.x, position.y, position.z, false, false, false, true);
  25.     ClearPedTasksImmediately(ped);
  26.    
  27.     while not HasCollisionLoadedAroundEntity(ped) do Citizen.Wait(0) end;
  28.    
  29.     DoScreenFadeIn(1500);
  30.     while IsScreenFadingIn() do Citizen.Wait(0) end;
  31. end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement