SA-MP Forums Archive
[Tutorial] Creating a new NPC - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Creating a new NPC (/showthread.php?tid=95034)

Pages: 1 2 3 4 5 6 7 8


Re: Creating a new NPC - danish007 - 13.12.2014

getting this

Quote:

D:\Danish Q\SA-MP Scripts\Deathmatch Server\gamemodes\DM.pwn(24) : warning 235: public function lacks forward declaration (symbol "OnRecordingPlaybackEnd")
D:\Danish Q\SA-MP Scripts\Deathmatch Server\gamemodes\DM.pwn(24) : error 017: undefined symbol "StartRecordingPlayback"
D:\Danish Q\SA-MP Scripts\Deathmatch Server\gamemodes\DM.pwn(30) : warning 235: public function lacks forward declaration (symbol "OnNPCSpawn")
D:\Danish Q\SA-MP Scripts\Deathmatch Server\gamemodes\DM.pwn(30) : error 017: undefined symbol "StartRecordingPlayback"




Re: Creating a new NPC - bogushas - 02.01.2015

PHP Code:
public OnPlayerRequestClass(playeridclassid)
{
    if(
IsPlayerNPC(playerid))
    {
        new 
npc_name[24];
        
GetPlayerName(playerid,npc_name,sizeof(npc_name));
        if(!
strcmp(npc_name,"Pablas",false)) SetSpawnInfo(playerid, -1,17, -1448.2899171494.7772226.099233,0.0, -1, -1, -1, -1, -1, -1);
    }   
    return 
1;

PHP Code:
[21:13:59] [npc:joinPablas has joined the server (0:127.0.0.1)
[
21:14:00] [npc:partPablas has left the server (0:2



Re: Creating a new NPC - Glossy42O - 02.01.2015

Very useful

Thanks. repfou


Re: Creating a new NPC - Arxalan - 04.01.2015

Nice Tutorial.


Re: Creating a new NPC - dan40o - 10.01.2015

says only incoming message. It doesn't join. What should i do?


Re: Creating a new NPC - Wipe - 10.01.2015

Quite useful and quality guide. Good job.


How to get unlimited nitrogen - oppo1234 - 13.01.2015

How to get unlimited nitrogen


Re: Creating a new NPC - Devil143 - 06.03.2015

I'm having error 017..How to solve..

\gamemodes\grandlarc.pwn(93) : error 017: undefined symbol "AkashVehicle"

Quote:

if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "Akash", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, AkashVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
return 1;
}




Re: Creating a new NPC - edwardluciano - 15.03.2015

Thankyou


Re: Creating a new NPC - Pearson - 07.06.2015

When NPC Connects It Disconects.Help Me Please


Re: Creating a new NPC - ammaz - 16.07.2015

Can anyone give me the correct code of allowing NPCs through login / register area?


Re: Creating a new NPC - MohammedZ - 09.08.2015

Nice tutorial, Actually I used it


Re: Creating a new NPC - Gotham - 08.09.2016

MY NPC does not spawn,
Is it because of OnPlayerSpawn?
I didn't add anything on it


Re: Creating a new NPC - FreAkeD - 08.09.2016

Quote:
Originally Posted by Gotham
View Post
MY NPC does not spawn,
Is it because of OnPlayerSpawn?
I didn't add anything on it
https://sampwiki.blast.hk/wiki/OnPlayerSpawn

OnPlayerSpawn is called when a player or NPC in the case of this tutorial is spawned, so try adding the OnPlayerSpawn code and see if it worked.


need help with the second and therd npc - yonik1988 - 14.03.2018

all the npc joins the server buth onli first one enters the vehicle ( tram ) the other 2 just stai in the spwn area here is my scripting

new Nea_spagatuVehicle; //Global variable!
new AndreyVehicle; //Global variable!
new LocotenentuVehicle; //Global variable!

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=OnPlayerSpawn=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "Nea_spagatu", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, Nea_spagatuVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
return 1;
}
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "Andrey", true))
{
PutPlayerInVehicle(playerid, AndreyVehicle, 0);
return 1;
}

GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "Locotenentu", true))
{
PutPlayerInVehicle(playerid, LocotenentuVehicle, 0);
return 1;
}
if(IsPlayerNPC(playerid))
{
SetPlayerSkin(playerid,PlayerInfo[playerid][pChar]);
GivePlayerWeapon(playerid,30,99999);
return 1;
}
etc

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=OnGameModeInit=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
public OnGameModeExit()
{

print("my gamemode");
ConnectNPC("Nea_Spagatu","yonik17");
Nea_spagatuVehicle = CreateVehicle(449, 0.0, 0.0, 7.0, 0.0, 249, 7, 5000);

print("my gamemode");
ConnectNPC("Locotenentu","airport");
LocotenentuVehicle = CreateVehicle(497, 0.0, 0.0, 7.0, 0.0, 231, 3, 5000);

print("my gamemode");
ConnectNPC("Andrey","buss");
AndreyVehicle = CreateVehicle(431, 0.0, 0.0, 7.0, 0.0, 2423, 5, 5000);

i have created the vehle myself, if i do not create them it does not create the vehile and now that i have create them it changes the id of all other vehiles how can i fix all this please


Re: Creating a new NPC - yonik1988 - 30.06.2018

hello there, i have a question, how many vehicle can you create for npc's and if more then 1 then how, i have created some npc's and 2 of them are in vehicle or it shold be buth only 1 vehilce is created and i can put the npc in it the second vehicle is not created... the problem is that i wanet to create event the theard viehicle and put a npc in it buth since i can not make the second vehicle ....so please help


Re: Creating a new NPC - yonik1988 - 01.07.2018

Problem solved i have done it ... this is the new scripting
new Nea_spagatuVehicle; //Global variable!
new Nea_stranutVehicle; //Global variable!
new Nea_caisaVehicle; //Global variable!

public OnPlayerSpawn(playerid)
{

if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname,"Nea_spagatu",false))
{
SetPlayerSkin(playerid, 61); // your skin choice for NPC
}
if(!strcmp(npcname,"gina",false))
{
SetPlayerSkin(playerid, 55); // your skin choice for NPC
}
if(!strcmp(npcname,"Elvis1",false))
{
SetPlayerSkin(playerid, 80); // your skin choice for NPC
}
if(!strcmp(npcname,"Elvis2",false))
{
SetPlayerSkin(playerid, 81); // your skin choice for NPC
}
if(!strcmp(npcname,"mirela",false))
{
SetPlayerSkin(playerid, 63); // your skin choice for NPC
}
if(!strcmp(npcname,"narcisa",false))
{
SetPlayerSkin(playerid, 90); // your skin choice for NPC
}
if(!strcmp(npcname,"coredelusa",false))
{
SetPlayerSkin(playerid, 91); // your skin choice for NPC
}
if(!strcmp(npcname,"mirabela",false))
{
SetPlayerSkin(playerid, 91); // your skin choice for NPC
}
if(!strcmp(npcname,"frosa",false))
{
SetPlayerSkin(playerid, 89); // your skin choice for NPC
}
if(!strcmp(npcname,"peste",false))
{
SetPlayerSkin(playerid, 100); // your skin choice for NPC
}
if(!strcmp(npcname,"meclaren",false))
{
SetPlayerSkin(playerid, 122); // your skin choice for NPC
}
if(!strcmp(npcname,"nino",false))
{
SetPlayerSkin(playerid, 114); // your skin choice for NPC
}
if(!strcmp(npcname,"puiutzu",false))
{
SetPlayerSkin(playerid, 144); // your skin choice for NPC
}
if(!strcmp(npcname,"gigi",false))
{
SetPlayerSkin(playerid, 156); // your skin choice for NPC
}
if(!strcmp(npcname,"Nea_stranut",false))
{
SetPlayerSkin(playerid, 274); // your skin choice for NPC
}
if(!strcmp(npcname,"Nea_caisa",false))
{
SetPlayerSkin(playerid, 253); // your skin choice for NPC
}
if(!strcmp(npcname, "Nea_spagatu", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, Nea_spagatuVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
if(!strcmp(npcname, "Nea_stranut", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, Nea_stranutVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
if(!strcmp(npcname, "Nea_caisa", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, Nea_caisaVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
return 1;
}

if(IsPlayerNPC(playerid))
{
SetPlayerSkin(playerid,PlayerInfo[playerid][pChar]);
GivePlayerWeapon(playerid,30,99999);
return 1;
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=OnGameModeInit=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
public OnGameModeExit()
{

print("my gamemode");
ConnectNPC("Nea_spagatu","yonik17");
Nea_spagatuVehicle = CreateVehicle(449, 0.0, 0.0, 7.0, 0.0, 249, 7, 5000);

print("my gamemode");
ConnectNPC("Nea_stranut","pilot");
Nea_stranutVehicle = CreateVehicle(487, 0.0, 0.0, 7.0, 0.0, 1, 1, 5000);

print("my gamemode");
ConnectNPC("Nea_caisa","soferu");
Nea_caisaVehicle = CreateVehicle(431, 0.0, 0.0, 7.0, 0.0, 1, 1, 5000);


i have added skins to... i tried to do this for a few years now ... thx for nothing