Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RegisterNetEvent("character:spawn");
- AddEventHandler("character:spawn", function(model, position)
- if not model or not position or not position.x or not position.y or not position.z then
- Citizen.Trace("This event requires character's model and position information!");
- return;
- end;
- DoScreenFadeOut(1500);
- while IsScreenFadingOut() do Citizen.Wait(0) end;
- -- load & change model
- local ready = false;
- TriggerEvent("model:change", model, CallbackAdd(function() ready = true; end));
- -- wait for model change confirm
- while not ready do Citizen.Wait(0) end;
- -- spawn player ped on selected position
- local ped = PlayerPedId();
- position.z = position.z + 0.25;
- RequestCollisionAtCoord(position.x, position.y, position.z);
- NetworkResurrectLocalPlayer(position.x, position.y, position.z, 0.0, true, true, false);
- SetEntityCoordsNoOffset(ped, position.x, position.y, position.z, false, false, false, true);
- ClearPedTasksImmediately(ped);
- while not HasCollisionLoadedAroundEntity(ped) do Citizen.Wait(0) end;
- DoScreenFadeIn(1500);
- while IsScreenFadingIn() do Citizen.Wait(0) end;
- end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement