SA-MP Forums Archive
Problem with NPC, help please - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with NPC, help please (/showthread.php?tid=277612)



Problem with NPC, help please - Setkus - 18.08.2011

Hey guys!
I have a problem with npc. Well, everything works with him but i have some online text draw and in this text draw include my npc, but he is just a bot, not a player. So is it possible to not include npc in online players? I hope you understand me. Sorry for my bad english, im Lithuanian


Re: Problem with NPC, help please - iPLEOMAX - 18.08.2011

Add something like this in your code: if( IsPlayerConnected(i) && !IsPlayerNPC(i) )....


Re: Problem with NPC, help please - Setkus - 18.08.2011

Could you give me an example?


Re: Problem with NPC, help please - iPLEOMAX - 18.08.2011

I hope you already made a textdraw showing how many connected players are there..

pawn Код:
//On top of your script (Global Var)
new g_ConnectedPlayers;

//Default functions:
public OnPlayerConnect(playerid)
{
    if(!IsPlayerNPC(playerid)) g_ConnectedPlayers++;
    UpdatePlayersTextDraw();
    return 1;
}
public OnPlayerDisconnect(playerid)
{
    if(!IsPlayerNPC(playerid)) g_ConnectedPlayers--;
    UpdatePlayersTextDraw();
    return 1;
}

//new stock function, put it anywhere outside other functions
stock UpdatePlayersTextDraw()
{
    new players[32];
    format(players, sizeof players, "Players: %i/100", g_ConnectedPlayers);
    TextDrawSetString(/* TextDraw Name */, players);
}