1
0

gl_npcs.pwn 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //-------------------------------------------------
  2. //
  3. // NPC initialisation for Grand Larceny
  4. //
  5. //-------------------------------------------------
  6. #pragma tabsize 0
  7. #include <a_samp>
  8. //-------------------------------------------------
  9. public OnFilterScriptInit()
  10. {
  11. ConnectNPC("TrainDriverLV","train_lv");
  12. ConnectNPC("TrainDriverLS","train_ls");
  13. ConnectNPC("TrainDriverSF","train_sf");
  14. ConnectNPC("PilotLV","at400_lv");
  15. ConnectNPC("PilotSF","at400_sf");
  16. ConnectNPC("PilotLS","at400_ls");
  17. // Testing
  18. //ConnectNPC("TestIdle","onfoot_test");
  19. //ConnectNPC("TaxiTest","mat_test");
  20. return 1;
  21. }
  22. //-------------------------------------------------
  23. // IMPORTANT: This restricts NPCs connecting from
  24. // an IP address outside this server. If you need
  25. // to connect NPCs externally you will need to modify
  26. // the code in this callback.
  27. public OnPlayerConnect(playerid)
  28. {
  29. if(IsPlayerNPC(playerid)) {
  30. new ip_addr_npc[64+1];
  31. new ip_addr_server[64+1];
  32. GetServerVarAsString("bind",ip_addr_server,64);
  33. GetPlayerIp(playerid,ip_addr_npc,64);
  34. if(!strlen(ip_addr_server)) {
  35. ip_addr_server = "127.0.0.1";
  36. }
  37. if(strcmp(ip_addr_npc,ip_addr_server,true) != 0) {
  38. // this bot is remote connecting
  39. printf("NPC: Got a remote NPC connecting from %s and I'm kicking it.",ip_addr_npc);
  40. Kick(playerid);
  41. return 0;
  42. }
  43. printf("NPC: Connection from %s is allowed.",ip_addr_npc);
  44. }
  45. return 1;
  46. }
  47. //-------------------------------------------------
  48. public OnPlayerRequestClass(playerid, classid)
  49. {
  50. if(!IsPlayerNPC(playerid)) return 0; // We only deal with NPC players in this script
  51. new playername[64];
  52. GetPlayerName(playerid,playername,64);
  53. if(!strcmp(playername,"TrainDriverLV",true)) {
  54. SetSpawnInfo(playerid,69,255,1462.0745,2630.8787,10.8203,0.0,-1,-1,-1,-1,-1,-1);
  55. }
  56. else if(!strcmp(playername,"TrainDriverSF",true)) {
  57. SetSpawnInfo(playerid,69,255,-1942.7950,168.4164,27.0006,0.0,-1,-1,-1,-1,-1,-1);
  58. }
  59. else if(!strcmp(playername,"TrainDriverLS",true)) {
  60. SetSpawnInfo(playerid,69,255,1700.7551,-1953.6531,14.8756,0.0,-1,-1,-1,-1,-1,-1);
  61. }
  62. else if(!strcmp(playername,"PilotLV",true)) {
  63. SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
  64. }
  65. else if(!strcmp(playername,"PilotSF",true)) {
  66. SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
  67. }
  68. else if(!strcmp(playername,"PilotLS",true)) {
  69. SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
  70. }
  71. else if(!strcmp(playername,"TestIdleDriver",true)) {
  72. SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
  73. }
  74. else if(!strcmp(playername,"TaxiTest",true)) {
  75. SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
  76. }
  77. return 0;
  78. }
  79. //-------------------------------------------------
  80. public OnPlayerSpawn(playerid)
  81. {
  82. if(!IsPlayerNPC(playerid)) return 1; // We only deal with NPC players in this script
  83. new playername[64];
  84. GetPlayerName(playerid,playername,64);
  85. if(!strcmp(playername,"TrainDriverLV",true)) {
  86. PutPlayerInVehicle(playerid,1,0);
  87. SetPlayerColor(playerid,0xFFFFFFFF);
  88. }
  89. else if(!strcmp(playername,"TrainDriverSF",true)) {
  90. PutPlayerInVehicle(playerid,5,0);
  91. SetPlayerColor(playerid,0xFFFFFFFF);
  92. }
  93. else if(!strcmp(playername,"TrainDriverLS",true)) {
  94. PutPlayerInVehicle(playerid,9,0);
  95. SetPlayerColor(playerid,0xFFFFFFFF);
  96. }
  97. else if(!strcmp(playername,"PilotLV",true)) {
  98. PutPlayerInVehicle(playerid,13,0);
  99. SetPlayerColor(playerid,0xFFFFFFFF);
  100. }
  101. else if(!strcmp(playername,"PilotSF",true)) {
  102. PutPlayerInVehicle(playerid,14,0);
  103. SetPlayerColor(playerid,0xFFFFFFFF);
  104. }
  105. else if(!strcmp(playername,"PilotLS",true)) {
  106. PutPlayerInVehicle(playerid,15,0);
  107. SetPlayerColor(playerid,0xFFFFFFFF);
  108. }
  109. else if(!strcmp(playername,"TestIdleDriver",true)) {
  110. PutPlayerInVehicle(playerid,43,0);
  111. SetPlayerColor(playerid,0xFFFFFFFF);
  112. }
  113. else if(!strcmp(playername,"TaxiTest",true)) {
  114. PutPlayerInVehicle(playerid,968,0);
  115. SetPlayerColor(playerid,0xFFFFFFFF);
  116. }
  117. return 1;
  118. }
  119. //-------------------------------------------------
  120. // EOF