Mass NPC Creation problem - Crash error? -
millzyman - 07.12.2009
Hi.
I was trying to efficently and quickly make npc's rather than doing them one by one by one etc. And when i went to test my script, i get a rather depressing crash report from samp. I am sure it is my scripting which is the problem so i am hoping someone can give me a solution or fix this problem.
Note: All variables have been defined and do not return errors.
Код:
new i = 0;
new script[50];
while(i<50)
{
new Randomscript = random(5);
format(NConnect,sizeof(NConnect),"NVehicle%d",i);
format(script,sizeof(script),"car%d",Randomscript);
ConnectNPC(NConnect[i],script[i]);
halt(20);
}
On 'OnPlayerSpawn'
Код:
if(IsPlayerNPC(playerid))
{
new RandomCar = random(6);
if (RandomCar == 0)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
NCar[playerid]=CreateVehicle(400,x,y,z,0,0,1,1);
}
if (RandomCar == 1)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
NCar[playerid]=CreateVehicle(404,x,y,z,0,0,1,1);
}
if (RandomCar == 2)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
NCar[playerid]=CreateVehicle(410,x,y,z,0,0,1,1);
}
if (RandomCar == 3)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
NCar[playerid]=CreateVehicle(421,x,y,z,0,0,1,1);
}
if (RandomCar == 4)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
NCar[playerid]=CreateVehicle(439,x,y,z,0,0,1,1);
}
if (RandomCar == 5)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
NCar[playerid]=CreateVehicle(445,x,y,z,0,0,1,1);
}
PutPlayerInVehicle(playerid,NCar[playerid],0);
return 1;
}
I am possibly thinking that it maybe that i am trying to halt a script in a while loop which may cause some kind of conflict i guess? If so is there anyway to get around this or fix it?
The Idea:
The idea is that i use a few path recordings to make plenty of NPC's to use so i make the road look busy.
Edit:
This is the serverlog when i start the server. I have done these npcs on grandlarc just so you know.
Quote:
SA-MP Dedicated Server
----------------------
v0.3a R3, ©2005-2009 SA-MP Team
[00:23:05]
[00:23:05] Server Plugins
[00:23:05] --------------
[00:23:05] Loaded 0 plugins.
[00:23:05]
[00:23:05] Filter Scripts
[00:23:05] ---------------
[00:23:05] Loaded 0 filter scripts.
[00:23:07] --- Server Shutting Down.
|
Re: Mass NPC Creation problem - Crash error? -
DJDhan - 07.12.2009
Bro,if multiple npc's use the same recording,they all will be crushed into each other while playback
So i guess you just have to record them one by one like me...I have had no problems.
Re: Mass NPC Creation problem - Crash error? -
millzyman - 07.12.2009
thats what halt() was for. I thought halt might seperate the path between them. Oh and now my gamemode doesn't even register as a server. For some reason when i try to join is says i am connected but just leaves me on joining game...
Re: Mass NPC Creation problem - Crash error? -
Joe Staff - 07.12.2009
You can't connect to your server because your loop is never ending, you didn't increment
i in it. Also you don't need multiple scripts, you can have all of your NPCs use the same script, just make the npcmode react differently to different NPC names.
Re: Mass NPC Creation problem - Crash error? -
millzyman - 07.12.2009
BAH! Thats the second time this week i have missed out something that simple. It would explain why i found a thousand copys of samp-npc running.
I want multible scripts though :P but thanks for your help guys.