Alive Textdraw Help -
RJTabish - 04.03.2019
Hi i'm learning on textdraws base systems but sometime i'm confused and having no idea i tried alot time to make players alive textdraws system but always i'm fail so hopefully you will help me i made textdraws but how to update it when player join and left then textdraws works like pubg alive textdraw
PHP код:
Textdrawpubg100 = TextDrawCreate(36.000000, 316.166778, "ALIVE");
TextDrawLetterSize(Textdrawpubg100, 0.449999, 1.600000);
TextDrawAlignment(Textdrawpubg100, 1);
TextDrawColor(Textdrawpubg100, -5963521);
TextDrawUseBox(Textdrawpubg100, true);
TextDrawBoxColor(Textdrawpubg100, 0);
TextDrawSetShadow(Textdrawpubg100, 0);
TextDrawSetOutline(Textdrawpubg100, 1);
TextDrawBackgroundColor(Textdrawpubg100, 51);
TextDrawFont(Textdrawpubg100, 1);
TextDrawSetProportional(Textdrawpubg100, 1);
Thank You In Advance
Re: Alive Textdraw Help -
masuzaron - 04.03.2019
Make a new variable ( For example new cPlayers; )
Count alive players by looping through all players and check if they are alive. If they are, increase cPlayers with +1 (cPlayers++), and than use this
https://sampwiki.blast.hk/wiki/TextDrawSetString This can help you. (Take a look in the example below)
Re: Alive Textdraw Help -
SymonClash - 04.03.2019
pawn Код:
new CountPUBGPlayers = -1;
When someone joins PUBG event:
When someone dies/left:
Showing players alive:
pawn Код:
new string[10];
format(string, sizeof string, "%d alive", CountPUBGPlayers);
Now it's up to you on how update the textdraw.
If you want to restrict and allowing PUBG event just when X players are joined, you can do:
pawn Код:
#define MIN_PLAYERS_REQUIRED 5 //(Change it as your needs)
If you have a command to join the PUBG event, then:
pawn Код:
CMD:pubg(playerid)
{
if(CountPUBGPlayers < MIN_REQUIRED_PLAYERS) return SendClientMessage("#MIN_REQUIRED_PLAYERS" players are neeeded to join PUBG event.");
return 1;
}
Re: Alive Textdraw Help -
RJTabish - 04.03.2019
Like This
PHP код:
#include <a_samp>
#include <zcmd>
new CountPUBGPlayers = -1;
CMD:enter(playerid)
{
CountPUBGPlayers ++;
new string[10];
format(string, sizeof string, "%d alive", CountPUBGPlayers);
return 1;
}
CMD:exit(playerid)
{
CountPUBGPlayers --;
return 1;
}
Re: Alive Textdraw Help -
TheToretto - 04.03.2019
Why the value is set to -1 ? It should be simply 0, and yes your code is correct @RJTabish, (except your indentation..) but don't forget to add every exception, such as OnPlayerDeath, then, OnPlayerDisconnect, you will have to check if he is in the game or not, add a boolean variable for that:
pawn Код:
new
CountPUBGPlayers,
bool:gInGame[MAX_PLAYERS];
CMD:enter(playerid)
{
if(gInGame[playerid]) return 1;
gInGame[playerid] = true;
CountPUBGPlayers++;
UpdateAliveTD();
return 1;
}
CMD:exit(playerid)
{
if(!gInGame[playerid]) return 1;
gInGame[playerid] = true;
CountPUBGPlayers--;
UpdateAliveTD();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
cmd_exit(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
cmd_exit(playerid);
return 1;
}
UpdateAliveTD()
{
new string[10];
format(string, sizeof string, "%d alive", CountPUBGPlayers);
TextDrawSetString(Textdrawpubg100, string);
return 1;
}
Re: Alive Textdraw Help -
RJTabish - 04.03.2019
Thank You So Much I was Lookin for it for along time but finally someone has response i'm very thankfull to you @TheTerotto Blesses For ya brother
Re: Alive Textdraw Help -
Pottus - 04.03.2019
Might be a good idea to also add a validation routine that makes sure the player count is correct. If for some reason it isn't then you can print the error so you know something is wrong. You can always just comment out that check later on when you see your system has no holes.
I've always found with SA-MP it's good to expect stuff not to work as expected under unusual or rare circumstances so it doesn't hurt to put in an loop here and there and do some validation checks.