QuoteThis will return a function object which can be used as if it is the remote function itself.(except of return values)So r will always be true.
npclist<-array(100, false);
function RegisterNPC(playerid, isnpc)
{
npclist[playerid]=isnpc;
}
function OnPlayerStreamIn(playerid)
{
print("I see the " GetPlayerName(playerid) " enter my field of view, and his ID is: " playerid ".");
local r=npclist[playerid];
if(r)print(" He is an npc\n");
}
//--server side//when a new player joins inform all npcs if the player is PC(Playable Character) or NPC(Non Playable Character).
function onPlayerJoin(player)
{
local plr;
for(local i=0;i<GetMaxPlayers();i )
{
plr = FindPlayer(i);
if(plr && plr.IsNPC)
{
//Send information
RFC(i, "RegisterNPC")(player.ID, player.IsNPC);
}
}
//When an npc joins the server send information about all existing Characters (Playable or Non Playable) to it.
if(player.IsNPC)
{
for(local i=0;i<GetMaxPlayers();i++)
{
plr= FindPlayer(i);
if(plr)
RFC(player.ID, "RegisterNPC")(i, plr.IsNPC);
}
}
}
1. IsNPC or IsNPC()
DiePos<-{}; //Create a table where you can store coordinates
function onPlayerPart(player, reason) {
if (DiePos.rawin(player.ID))
DiePos.rawdelete(player.ID);
}
function onPlayerSpawn(player)
{
if(DiePos.rawin(player.ID)) //If an ID exists in the table
{
player.Pos=DiePos.rawget(player.ID); //Restores the player to death point
DiePos.rawdelete(player.ID); //Delete coordinates after recovery
}
}
function onPlayerDeath(player,reason)
{
if(reason!=43)
{
DiePos.rawset(player.ID,player.Pos); //After the player dies, the ID is used as the search object, and the death coordinates are stored in the table
}
}
Quote from: PSL on Mar 09, 2024, 08:11 AMThe following code may help youDiePos<-{}; //Create a table where you can store coordinates
function onPlayerSpawn(player)
{
if(DiePos.rawin(player.ID)) //If an ID exists in the table
{
player.Pos=DiePos.rawget(player.ID); //Restores the player to death point
DiePos.rawdelete(player.ID); //Delete coordinates after recovery
}
}
function onPlayerDeath(player,reason)
{
DiePos.rawset(player.ID,player.Pos); //After the player dies, the ID is used as the search object, and the death coordinates are stored in the table
}
function onPlayerPart(player, reason) {
if (DiePos.rawin(player.ID))
DiePos.rawdelete(player.ID);
}
function OnPlayerStreamIn(playerid)
{
print("I see the "+GetPlayerName(playerid)+" enter my field of view, and his ID is: "+playerid+".");
local r=RFC("IsPlayerNPC")(playerid);
print(""+r+""); //Always return true
}
DiePos<-{}; //Create a table where you can store coordinates
function onPlayerSpawn(player)
{
if(DiePos.rawin(player.ID)) //If an ID exists in the table
{
player.Pos=DiePos.rawget(player.ID); //Restores the player to death point
DiePos.rawdelete(player.ID); //Delete coordinates after recovery
}
}
function onPlayerDeath(player,reason)
{
DiePos.rawset(player.ID,player.Pos); //After the player dies, the ID is used as the search object, and the death coordinates are stored in the table
}