Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //v_NPC v1.1.4 by Vandex Corporation
- /*
- native vNPC_CreateNPC(name[MAX_PLAYER_NAME], script[32], skinid, bool:usecolor, color = -1, vehmodelid = -1, vehcolor1 = 1, vehcolor2 = 1);
- native vNPC_ConnectNPC(npcid);
- native vNPC_DisconnectNPC(npcid);
- */
- #define MAX_VNPCS 50
- enum vIncNPC {
- vIncName[MAX_PLAYER_NAME],
- vIncScript[32],
- vIncSkinid,
- vIncColor,
- vIncVehModelid,
- vIncPlayerid,
- //bool:vIncSpawned,
- vIncVehColor1,
- vIncVehColor2,
- vIncVeh,
- bool:vIncJustJoin,
- bool:vIncColorUsed,
- }
- new vIncNPCInfo[MAX_VNPCS][vIncNPC], vIncNextNPC;
- stock vNPC_CreateNPC(name[MAX_PLAYER_NAME], script[32], skinid, bool:usecolor, color = -1, vehmodelid = -1, vehcolor1 = 1, vehcolor2 = 1) {
- vIncNPCInfo[vIncNextNPC][vIncName] = name;
- vIncNPCInfo[vIncNextNPC][vIncScript] = script;
- vIncNPCInfo[vIncNextNPC][vIncSkinid] = skinid;
- vIncNPCInfo[vIncNextNPC][vIncColor] = color;
- vIncNPCInfo[vIncNextNPC][vIncColorUsed] = usecolor;
- vIncNPCInfo[vIncNextNPC][vIncVehModelid] = vehmodelid;
- vIncNPCInfo[vIncNextNPC][vIncPlayerid] = -1;
- //vIncNPCInfo[vIncNextNPC][vIncSpawned] = false;
- vIncNPCInfo[vIncNextNPC][vIncVehColor1] = vehcolor1;
- vIncNPCInfo[vIncNextNPC][vIncVehColor2] = vehcolor2;
- vIncNPCInfo[vIncNextNPC][vIncJustJoin] = false;
- vIncNextNPC ++;
- return vIncNextNPC-1;
- }
- stock vNPC_ConnectNPC(npcid) {
- if(vIncNPCInfo[npcid][vIncPlayerid] != -1){
- print("[v_NPC] Error 002: NPC is already connected!");
- } else {
- ConnectNPC(vIncNPCInfo[npcid][vIncName], vIncNPCInfo[npcid][vIncScript]);
- vIncNPCInfo[npcid][vIncJustJoin] = true;
- }
- }
- stock vNPC_DisconnectNPC(npcid) {
- if(vIncNPCInfo[npcid][vIncPlayerid] != -1) {
- Kick(vIncNPCInfo[npcid][vIncPlayerid]);
- vIncNPCInfo[npcid][vIncPlayerid] = -1;
- if(vIncNPCInfo[npcid][vIncVehModelid] != -1) {
- DestroyVehicle(vIncNPCInfo[npcid][vIncVeh]);
- }
- } else {
- print("[v_NPC] Error 001: NPC is not connected!");
- }
- }
- stock vNPC_OnPlayerConnect(playerid) {
- if(IsPlayerNPC(playerid)) {
- for(new i; i < vIncNextNPC; i++) {
- if(vIncNPCInfo[i][vIncJustJoin] == true) {
- vIncNPCInfo[i][vIncJustJoin] = false;
- vIncNPCInfo[i][vIncPlayerid] = playerid;
- }
- }
- }
- }
- stock vNPC_OnPlayerSpawn(playerid) {
- if(IsPlayerNPC(playerid)) {
- for(new i; i < vIncNextNPC; i++) {
- if(vIncNPCInfo[i][vIncPlayerid] == playerid) {
- for(new p; p < MAX_PLAYERS; p++) {
- if(vIncNPCInfo[i][vIncColorUsed] == true){
- SetPlayerMarkerForPlayer(p, playerid, vIncNPCInfo[i][vIncColor]);
- } else {
- SetPlayerMarkerForPlayer(p, playerid, 0xFFFFFF00);
- }
- }
- if(vIncNPCInfo[i][vIncVehModelid] != -1){
- vIncNPCInfo[i][vIncVeh] = CreateVehicle(vIncNPCInfo[i][vIncVehModelid], 0, 0, 0, 0, vIncNPCInfo[i][vIncVehColor1], vIncNPCInfo[i][vIncVehColor2], -1);
- PutPlayerInVehicle(playerid, vIncNPCInfo[i][vIncVeh], 0);
- }
- SetPlayerSkin(vIncNPCInfo[i][vIncPlayerid], vIncNPCInfo[i][vIncSkinid]);
- }
- }
- return 1;
- } else {
- for(new i; i < vIncNextNPC; i++) {
- for(new p; p < MAX_PLAYERS; p++) {
- if(vIncNPCInfo[i][vIncColorUsed] == true){
- SetPlayerMarkerForPlayer(playerid, p, vIncNPCInfo[i][vIncColor]);
- } else {
- SetPlayerMarkerForPlayer(playerid, p, 0xFFFFFF00);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement