Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- NPC Help by Sayaron
- This is a small guide that helps you to make NPCs in vehicles
- What is required for it to work?:
- -A NPC record (Use the filterscript npc_record wich is included in the sa-mp folder at download. The file will be in "npcmodes" > "recordings")
- -A npcmode that reefers to the NPC record (Look in the folder "npcmodes" to see how its done)
- */
- #include <a_samp>
- new YourVehicle; // The name of your vehicle
- public OnGameModeInit()
- {
- ConnectNPC("YourNPC","RecordName"); // The name of your NPC and the record. The record need to match an record with the same name. The NPC name can be anything
- YourVehicle = AddStaticVehicle(448,2076.4067,2227.7834,10.4165,178.8465,6,6); // Creating your vehicle, this can be done ingame by typing /save. Then go to your SA-MP folder and find the folder "savedpositions"
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(!IsPlayerNPC(playerid)) return 0; // If the player is not a NPC, nothing will happend
- new playername[64]; //Player String
- GetPlayerName(playerid,playername,64); //This is to get the NPC's name
- if(!strcmp(playername, "YourNPC", true)) { // Detecting if the NPC is spawned. If it is not spawned or the name is wrong, nothing will happend
- SetSpawnInfo( playerid, 0, 255, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
- //SetSpawnInfo( playerid, Team, Skin, x, y, z, rotation, weapon1, ammo for weapon1, w2, ammo2, w3, ammo3 );
- SetPlayerColor(playerid,0xFFFFFFFF); // Chose any color you want, this is currently white
- PutPlayerInVehicle(playerid, YourVehicle, 0);
- //PutPlayerInVehicle(playerid, vehiclename, seat);
- }
- return 1;
- }
- // This is to stop remote bots to connect, it will only let your bots connect
- // If you dont want it, you may remove it
- public OnPlayerConnect(playerid)
- {
- if(IsPlayerNPC(playerid)) {
- new ip_addr_npc[64+1];
- new ip_addr_server[64+1];
- GetServerVarAsString("bind",ip_addr_server,64);
- GetPlayerIp(playerid,ip_addr_npc,64);
- if(!strlen(ip_addr_server)) {
- ip_addr_server = "127.0.0.1";
- }
- if(strcmp(ip_addr_npc,ip_addr_server,true) != 0) {
- // this bot is remote connecting
- printf("NPC: Got a remote NPC connecting from %s and I'm kicking it.",ip_addr_npc);
- Kick(playerid);
- return 0;
- }
- printf("NPC: Connection from %s is allowed.",ip_addr_npc);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement