05.12.2010, 18:49
if i connect a npc while ingame the server crashes.
if i connect a npc ongamemodeinit the server doesnt not load properly (this was the cause kalcor)
i think its a conflict with mapandreas and a npc S:
npc code.
edit - its a 0.3b bot
if i connect a npc ongamemodeinit the server doesnt not load properly (this was the cause kalcor)
i think its a conflict with mapandreas and a npc S:
npc code.
edit - its a 0.3b bot
pawn Код:
#define RECORDING "Jessica" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 2 //1 for in vehicle and 2 for on foot.
#include <a_npc>
forward OnNPCUpdate(npcid);
forward OnNPCGetDamage(npcid,Float:damage);
new phealth;
main()
{}
public OnNPCModeInit()
{
printf("NPC script loaded");
}
public OnNPCModeExit()
{
print("NPC script unloaded");
}
public OnNPCConnect(myplayerid)
{
printf("I successfully connected the server with ID %i!", myplayerid);
SetTimer("OnNPCUpdate",50,true);
}
public OnNPCDisconnect(reason[])
{
printf("Disconnected from the server. %s", reason);
}
public OnNPCUpdate(npcid)
{
static Float:HP,Float:Armour;
HP = GetPlayerHealth(npcid);
Armour = GetPlayerArmour(npcid);
if(HP+Armour < phealth)
{
OnNPCGetDamage(npcid,floatround(phealth-HP-Armour));
}
phealth=floatround(HP+Armour);
return 1;
}
public OnNPCGetDamage(npcid,Float:damage)
{
printf ( "OnNPCGetDamage ( %d, %f )", npcid, damage);
return 1;
}
public OnClientMessage(color, text[])
{
if(strfind(text,"Bank Balance: $0") != -1) SendChat("I am poor :(");
}
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); print("NPC spawned");
printf("Jessica");
SendChat("Hello World. I'm a bot.");
}
#endif
public OnPlayerStreamIn(playerid)
{
new string[80];
format(string, sizeof(string), "/pm %d Hello! I have just loaded you!", playerid);
SendCommand(string);
return 1;
}
public OnPlayerStreamOut(playerid)
{
new string[80];
format(string, sizeof(string), "Bye ID %i!", playerid);
SendChat(string);
return 1;
}
public OnPlayerDeath(playerid)
{
new string[80], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Oh no %s! I didn't want you to die that way!", name);
SendChat(string);
return 1;
}
public OnPlayerText(playerid, text[])
{
if (strfind(text, "stupid bot") != -1)
{
new string[80], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Hey %s! Don't say those things! We, bots, are cool!", name);
SendChat(string);
}
return 1;
}