NPC problem - 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)
+--- Thread: NPC problem (
/showthread.php?tid=298963)
NPC problem -
aminj - 23.11.2011
hey guys ive got a problem when i wanted to compile my gamemode after i pasted this script under OnGamemodeinit :
Код:
print("my gamemode");
ConnectNPC("MyFirstNPC","mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
i got this error:
Код:
E:\desktop\TE\gamemodes\TE.pwn(143) : warning 204: symbol is assigned a value that is never used: "MyFirstNPCVehicle"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
please help how to fix it?
Re: NPC problem -
Kostas' - 23.11.2011
You should use it on something. If you do not, it will gives you warning for this symbol is never used
pawn Код:
// At The Top
new MyFirstNPCVehicle;
// OnGameModeInit()
public OnGameModeInit()
{
print("my gamemode");
ConnectNPC("MyFirstNPC","mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
// Rest Of Code
return 1;
}
// OnPlayerSpawn(playerid)
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));
if(!strcmp(npcname, "MyFirstNPC", true))
{
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); // We Use It Here
}
return 1;
}
// Rest Of Code
return 1;
}
Re: NPC problem -
aminj - 24.11.2011
i tried that but i still get error. is it possible to add this to filter script? i mean is it possible to use the script you posted as a filter script?
Re: NPC problem -
Kostas' - 24.11.2011
This should be on the Gamemode or in Filterscript. it works for both cases.
pawn Код:
// At The Top
new MyFirstNPCVehicle;
// OnGameModeInit()
public OnGameModeInit()
{
print("my gamemode");
ConnectNPC("MyFirstNPC","mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
// Rest Of Code
return 1;
}
// OnPlayerSpawn(playerid)
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));
if(!strcmp(npcname, "MyFirstNPC", true))
{
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); // We Use It Here
}
return 1;
}
// Rest Of Code
return 1;
}
And this part should be in the <Your SA-MP server directory>/npcmodes/name.pwn
pawn Код:
#define RECORDING "mynpc" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#if RECORDING_TYPE == 1
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCExitVehicle() StopRecordingPlayback();
#else
public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#endif
Re: NPC problem -
aminj - 24.11.2011
sorry but i didnt understand

im new on scripting :S
Re: NPC problem -
Kostas' - 24.11.2011
Show me your NPC code that you have on Gamemode
Код:
desktop\TE\gamemodes\TE.pwn
Re: NPC problem -
aminj - 24.11.2011
i ont have npc on gamemode... its on npcmodes folder