Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using CitizenFX.Core;
- using static CitizenFX.Core.Native.API;
- namespace FiveMLifeClient
- {
- class Commands
- {
- async private void SpawnCar(int source, List<object> args, string raw)
- {
- // account for the argument not being passed
- var model = "adder";
- if (args.Count > 0)
- {
- model = args[0].ToString();
- }
- // Check if the model actually exists and if not
- // write out a message
- var hash = (uint)GetHashKey(model);
- if (!IsModelInCdimage(hash) || !IsModelAVehicle(hash))
- {
- this.ChatAddMessage($"Failed to spawn {model}");
- return;
- }
- // Create the vehicle
- var vehicle = await World.CreateVehicle(model, Game.PlayerPed.Position, Game.PlayerPed.Heading);
- // Set the player ped into the vehicle and driver seat
- Game.PlayerPed.SetIntoVehicle(vehicle, VehicleSeat.Driver);
- // Give message
- this.ChatAddMessage($"Spawned the {model} at your position. You are now also in the driver seat.");
- }
- }
- class ChatMessage
- {
- private int[] Color { get; }
- private string[] Message { get; }
- public ChatMessage(int[] color, string[] message)
- {
- this.Color = color;
- this.Message = message;
- }
- }
- static class Chat
- {
- static void SendChatMessage(string message)
- {
- int[] color = { 255, 0, 0 };
- string[] messageArgs = { "Client", message };
- ChatMessage chatMessage = new ChatMessage(color, messageArgs);
- TriggerEvent("chat:addMessage", chatMessage);
- }
- }
- public class Client : BaseScript
- {
- /// <summary>
- /// Constructor for class 1
- /// Does not return anything
- /// </summary>
- public Client()
- {
- EventHandlers["onClientResourceStart"] += new Action<string>(this.OnClientResourceStart);
- }
- /// <summary>
- /// When the client starts
- /// Does not return anything
- /// </summary>
- /// <param name="resourceName"></param>
- private void OnClientResourceStart(string resourceName)
- {
- // What is this??
- if (GetCurrentResourceName() != resourceName) return;
- RegisterCommand("car", new Action<int, List<object>, string>(this.SpawnCar), false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement