Advertisement
icorne

v_NPC - Include

Jan 13th, 2012
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.27 KB | None | 0 0
  1. //v_NPC v1.1.4 by Vandex Corporation
  2. /*
  3. native vNPC_CreateNPC(name[MAX_PLAYER_NAME], script[32], skinid, bool:usecolor, color = -1, vehmodelid = -1, vehcolor1 = 1, vehcolor2 = 1);
  4. native vNPC_ConnectNPC(npcid);
  5. native vNPC_DisconnectNPC(npcid);
  6. */
  7.  
  8. #define MAX_VNPCS 50
  9.  
  10. enum vIncNPC {
  11.     vIncName[MAX_PLAYER_NAME],
  12.     vIncScript[32],
  13.     vIncSkinid,
  14.     vIncColor,
  15.     vIncVehModelid,
  16.     vIncPlayerid,
  17.     //bool:vIncSpawned,
  18.     vIncVehColor1,
  19.     vIncVehColor2,
  20.     vIncVeh,
  21.     bool:vIncJustJoin,
  22.     bool:vIncColorUsed,
  23. }
  24. new vIncNPCInfo[MAX_VNPCS][vIncNPC], vIncNextNPC;
  25.  
  26. stock vNPC_CreateNPC(name[MAX_PLAYER_NAME], script[32], skinid, bool:usecolor, color = -1, vehmodelid = -1, vehcolor1 = 1, vehcolor2 = 1) {
  27.     vIncNPCInfo[vIncNextNPC][vIncName] = name;
  28.     vIncNPCInfo[vIncNextNPC][vIncScript] = script;
  29.     vIncNPCInfo[vIncNextNPC][vIncSkinid] = skinid;
  30.     vIncNPCInfo[vIncNextNPC][vIncColor] = color;
  31.     vIncNPCInfo[vIncNextNPC][vIncColorUsed] = usecolor;
  32.     vIncNPCInfo[vIncNextNPC][vIncVehModelid] = vehmodelid;
  33.     vIncNPCInfo[vIncNextNPC][vIncPlayerid] = -1;
  34.     //vIncNPCInfo[vIncNextNPC][vIncSpawned] = false;
  35.     vIncNPCInfo[vIncNextNPC][vIncVehColor1] = vehcolor1;
  36.     vIncNPCInfo[vIncNextNPC][vIncVehColor2] = vehcolor2;
  37.     vIncNPCInfo[vIncNextNPC][vIncJustJoin] = false;
  38.     vIncNextNPC ++;
  39.     return vIncNextNPC-1;
  40. }
  41.  
  42. stock vNPC_ConnectNPC(npcid) {
  43.     if(vIncNPCInfo[npcid][vIncPlayerid] != -1){
  44.         print("[v_NPC] Error 002: NPC is already connected!");
  45.     } else {
  46.         ConnectNPC(vIncNPCInfo[npcid][vIncName], vIncNPCInfo[npcid][vIncScript]);
  47.         vIncNPCInfo[npcid][vIncJustJoin] = true;
  48.     }
  49. }
  50.  
  51. stock vNPC_DisconnectNPC(npcid) {
  52.     if(vIncNPCInfo[npcid][vIncPlayerid] != -1) {
  53.         Kick(vIncNPCInfo[npcid][vIncPlayerid]);
  54.         vIncNPCInfo[npcid][vIncPlayerid] = -1;
  55.         if(vIncNPCInfo[npcid][vIncVehModelid] != -1) {
  56.             DestroyVehicle(vIncNPCInfo[npcid][vIncVeh]);
  57.         }
  58.     } else {
  59.         print("[v_NPC] Error 001: NPC is not connected!");
  60.     }
  61. }
  62.  
  63. stock vNPC_OnPlayerConnect(playerid) {
  64.     if(IsPlayerNPC(playerid)) {
  65.         for(new i; i < vIncNextNPC; i++) {
  66.             if(vIncNPCInfo[i][vIncJustJoin] == true) {
  67.                 vIncNPCInfo[i][vIncJustJoin] = false;
  68.                 vIncNPCInfo[i][vIncPlayerid] = playerid;
  69.             }
  70.         }
  71.     }
  72. }
  73.  
  74. stock vNPC_OnPlayerSpawn(playerid) {
  75.     if(IsPlayerNPC(playerid)) {
  76.         for(new i; i < vIncNextNPC; i++) {
  77.             if(vIncNPCInfo[i][vIncPlayerid] == playerid) {
  78.                 for(new p; p < MAX_PLAYERS; p++) {
  79.                     if(vIncNPCInfo[i][vIncColorUsed] == true){
  80.                         SetPlayerMarkerForPlayer(p, playerid, vIncNPCInfo[i][vIncColor]);
  81.                     } else {
  82.                         SetPlayerMarkerForPlayer(p, playerid, 0xFFFFFF00);
  83.                     }
  84.                 }
  85.                 if(vIncNPCInfo[i][vIncVehModelid] != -1){
  86.                     vIncNPCInfo[i][vIncVeh] = CreateVehicle(vIncNPCInfo[i][vIncVehModelid], 0, 0, 0, 0, vIncNPCInfo[i][vIncVehColor1], vIncNPCInfo[i][vIncVehColor2], -1);
  87.                     PutPlayerInVehicle(playerid, vIncNPCInfo[i][vIncVeh], 0);
  88.                 }
  89.                 SetPlayerSkin(vIncNPCInfo[i][vIncPlayerid], vIncNPCInfo[i][vIncSkinid]);
  90.             }
  91.         }
  92.         return 1;
  93.     } else {
  94.         for(new i; i < vIncNextNPC; i++) {
  95.             for(new p; p < MAX_PLAYERS; p++) {
  96.                 if(vIncNPCInfo[i][vIncColorUsed] == true){
  97.                     SetPlayerMarkerForPlayer(playerid, p, vIncNPCInfo[i][vIncColor]);
  98.                 } else {
  99.                     SetPlayerMarkerForPlayer(playerid, p, 0xFFFFFF00);
  100.                 }
  101.             }
  102.         }
  103.     }
  104.     return 1;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement