Advertisement
Guest User

Untitled

a guest
Sep 7th, 2018
2,899
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using GTANetworkAPI;
  3.  
  4. namespace blankscript
  5. {
  6.  
  7. public class blankscript : Script
  8. {
  9.  
  10. [ServerEvent(Event.ResourceStart)] //This type of event is mainly used for handling stuff after this resource has been initiated.
  11. public void ResourceStart()
  12. {
  13. Console.WriteLine("\n--------------------------------------");
  14. Console.WriteLine("Blank Script by your name here");
  15. Console.WriteLine("--------------------------------------\n");
  16. }
  17.  
  18. [Command("hi", Alias="hello, hey, howdy")]
  19. public void SayHi(Client player)
  20. {
  21. NAPI.Chat.SendChatMessageToPlayer(player, "Hello!");
  22. }
  23.  
  24. [Command("car")]
  25. public void CmdCreateCar(Client client, string type)
  26. {
  27. Vehicle newVehicle;
  28. uint myCarType = NAPI.Util.GetHashKey(type);
  29. newVehicle = NAPI.Vehicle.CreateVehicle(myCarType, client.Position.Around(5), 0, 7, 7);
  30. }
  31.  
  32. [Command("sethealth")]
  33. public void CmdSetHealth(Client client, int amount)
  34. {
  35. if (amount > 50)
  36. {
  37. client.Health = 100;
  38. return;
  39. }
  40.  
  41. if (amount < 5)
  42. {
  43. client.SendChatMessage("You can't set health lower than 5.");
  44. return;
  45. }
  46. client.Health = amount;
  47. client.SendChatMessage($"Your health has been set to: {amount}");
  48. }
  49.  
  50.  
  51.  
  52. [ServerEvent(Event.ResourceStop)] //This type of event is mainly used for handling stuff before resource termination.
  53. public void ResourceStop()
  54. {
  55. Console.WriteLine("Goodbye");
  56. }
  57.  
  58.  
  59.  
  60. [ServerEvent(Event.ResourceStartEx)] //This event is triggered when a resource starts.
  61. public void OnResourceStartEx(string resourceName)
  62. {
  63. NAPI.Chat.SendChatMessageToAll($"Resource {resourceName} got started!");
  64. }
  65.  
  66.  
  67.  
  68. [ServerEvent(Event.ResourceStopEx)] //This event is triggered when a resource stops.
  69. public void OnResourceStopEx(string resourceName)
  70. {
  71. NAPI.Chat.SendChatMessageToAll($"Resource {resourceName} is stopped!");
  72. }
  73.  
  74.  
  75.  
  76. [ServerEvent(Event.Update)] //This event is used for iterating code at server's tickrate.
  77. public void OnUpdate()
  78. {
  79.  
  80. }
  81.  
  82.  
  83.  
  84. [ServerEvent(Event.ChatMessage)] // Handling server chat.
  85. public void OnChatMessage(Client player, string message)
  86. {
  87. if (message.Contains("Foo"))
  88. {
  89. NAPI.Chat.SendChatMessageToPlayer(player, "Prohibited word!");
  90. return;
  91. }
  92. }
  93.  
  94.  
  95.  
  96. [ServerEvent(Event.PlayerConnected)] //This event is invoked once the player has finished loading all the required resources.
  97. public void OnPlayerConnected(Client player)
  98. {
  99. player.SendChatMessage($"Welcome to our server {player.Name}");
  100. }
  101.  
  102.  
  103.  
  104. [ServerEvent(Event.PlayerDisconnected)] //This type of event is used for handling code when the player disconnects.
  105. public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
  106. {
  107. switch (type)
  108. {
  109. case DisconnectionType.Left:
  110. NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has quit the server.");
  111. break;
  112.  
  113. case DisconnectionType.Timeout:
  114. NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has timed out.");
  115. break;
  116.  
  117. case DisconnectionType.Kicked:
  118. NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has been kicked for " + reason);
  119. break;
  120. }
  121. }
  122.  
  123.  
  124.  
  125. [ServerEvent(Event.PlayerDeath)] //This type of event is used for handling code when someone dies.
  126. public void OnPlayerDeath(Client player, Client killer, uint reason)
  127. {
  128. if (!killer.IsNull)
  129. {
  130. NAPI.Notification.SendNotificationToAll($"{killer.Name} killed {player.Name}");
  131. }
  132. else
  133. {
  134. NAPI.Notification.SendNotificationToAll($"{player.Name} died");
  135. }
  136. }
  137.  
  138.  
  139.  
  140. [ServerEvent(Event.PlayerSpawn)] //This type of event is used for handling your code when you spawn.
  141. public void OnPlayerSpawn(Client player)
  142. {
  143.  
  144. }
  145.  
  146.  
  147.  
  148. [ServerEvent(Event.PlayerPickup)] //This type of event is used for handling code when the character picks up a pickup entity.
  149. public void OnPlayerPickup(Client player, Pickup pickup)
  150. {
  151.  
  152. }
  153.  
  154.  
  155.  
  156. [ServerEvent(Event.PlayerDamage)] //This event is triggered when a player's health or armor changes.
  157. public void OnPlayerDamage(Client player, float healthLoss, float armorLoss)
  158. {
  159.  
  160. }
  161.  
  162.  
  163.  
  164. [ServerEvent(Event.PlayerEnterVehicle)] // This type of event is used for handling code when the player enters any type of vehicle.
  165. public void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seatID)
  166. {
  167. NAPI.Chat.SendChatMessageToPlayer(player, "You've entered the vehicle");
  168. }
  169.  
  170.  
  171.  
  172. [ServerEvent(Event.PlayerExitVehicle)] //This type of event is used for handling code when the player exits any type of vehicle.
  173. public void OnPlayerExitVehicle(Client player, Vehicle vehicle)
  174. {
  175. NAPI.Chat.SendChatMessageToPlayer(player, "You've left the vehicle");
  176. }
  177.  
  178.  
  179.  
  180. [ServerEvent(Event.PlayerWeaponSwitch)] //This event is triggered when a player changes weapon.
  181. public void OnPlayerWeaponSwitch(Client player, WeaponHash oldWeapon, WeaponHash newWeapon)
  182. {
  183.  
  184. }
  185.  
  186.  
  187.  
  188. [ServerEvent(Event.PlayerDetonateStickies)] //This event is triggered when a player detonate stickies.
  189. public void OnPlayerDetonateStickies(Client player)
  190. {
  191.  
  192. }
  193.  
  194.  
  195.  
  196. [ServerEvent(Event.PlayerEnterColshape)] //This type of event is used for handling code when the player enters a ColShape.
  197. public void OnPlayerEnterColshape(ColShape shape, Client player)
  198. {
  199.  
  200. }
  201.  
  202.  
  203.  
  204. [ServerEvent(Event.PlayerExitColshape)] //This event is triggered when a player exits a colshape.
  205. public void OnPlayerExitColShape(ColShape shape, Client player)
  206. {
  207.  
  208. }
  209.  
  210.  
  211.  
  212. [ServerEvent(Event.PlayerEnterCheckpoint)] //Event when player enters checkpoint.
  213. public void OnPlayerEnterCheckpoint(Checkpoint checkpoint, Client player)
  214. {
  215.  
  216. }
  217.  
  218.  
  219.  
  220. [ServerEvent(Event.PlayerExitCheckpoint)] //Event when player exits checkpoint.
  221. public void OnPlayerExitCheckpoint(Checkpoint checkpoint, Client player)
  222. {
  223.  
  224. }
  225.  
  226.  
  227.  
  228. [ServerEvent(Event.VehicleDamage)] //This event is triggered when a vehicle's health changes.
  229. public void OnVehicleDamageHandler(Vehicle vehicle, float bodyHealthLoss, float engineHealthLoss)
  230. {
  231.  
  232. }
  233.  
  234.  
  235.  
  236. [ServerEvent(Event.VehicleSirenToggle)] // This event is triggered when siren toggle.
  237. public void OnVehicleSirenToggle(Vehicle vehicle, bool oldValue)
  238. {
  239.  
  240. }
  241.  
  242.  
  243.  
  244. [ServerEvent(Event.VehicleDoorBreak)] //This event is triggered when a vehicle door break.
  245. public void OnVehicleDoorBreak(Vehicle vehicle, int doorIndex)
  246. {
  247.  
  248. }
  249.  
  250.  
  251.  
  252. [ServerEvent(Event.VehicleWindowSmash)] //This event is triggered when a vehicle window get smashed.
  253. public void OnVehicleWindowSmash(Vehicle vehicle, int windowIndex)
  254. {
  255.  
  256. }
  257.  
  258.  
  259.  
  260. [ServerEvent(Event.VehicleTyreBurst)] //This event is triggered when a vehicle tyre burst.
  261. public void OnVehicleTyreBurst(Vehicle vehicle, int tyreIndex)
  262. {
  263.  
  264. }
  265.  
  266.  
  267.  
  268. [ServerEvent(Event.VehicleDeath)] //This type of event is used for handling code when a vehicle gets destroyed.
  269. public void OnVehicleDeath(Vehicle veh)
  270. {
  271.  
  272. }
  273.  
  274.  
  275.  
  276. [ServerEvent(Event.VehicleTrailerChange)] //This event is triggered when a vehicle trailer change.
  277. public void OnVehicleTrailerChange(Vehicle vehicle, Vehicle trailer)
  278. {
  279.  
  280. }
  281. }
  282. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement