A little help with calling medics?
#1

Quote:
Originally Posted by Justas [SiJ
]
How can I check if there are no connected players in gTeam[i] == TEAM_MEDICS?
pawn Код:
dcmd_callmedics(playerid, params[])
{
    new place[256];
    new name [MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if (sscanf(params, "s", place)) UsageMsg(playerid, "Usage: /callmedics <your location>");
    else
    {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(gTeam[i] == TEAM_MEDICS)
        {
            SendFMessage(i,COLOR_SYSTEM,"Player %s needs for medics.",name);
            SendFMessage(i,COLOR_SYSTEM,"Location %s.",place);
            SystemMsg(playerid,"You have called for a medics. Do not move and wait for them.");
        }
    }
    return 1;
}
if I would do
pawn Код:
if(gTeam[i] == TEAM_MEDICS)
        {
            SendFMessage(i,COLOR_SYSTEM,"Player %s needs for medics.",name);
            SendFMessage(i,COLOR_SYSTEM,"Location %s.",place);
            SystemMsg(playerid,"You have called for a medics. Do not move and wait for them.");
        }
        else
        {
        //Send message to player that no medics are connected
        }
It would send message to player if there are at least one player who are NOT in TEAM_MEDICS.. Am I right?
Reply
#2

That line is creating a loop for the MAX_PLAYERS, which mostly is 200.
Reply
#3

so you can reset variables or something. its most often used at a mission with variables for each player.
Reply
#4

Ok, thanks for answers. I think I understood it now.
Reply
#5

How can I check if there are no connected players in gTeam[i] == TEAM_MEDICS?
pawn Код:
dcmd_callmedics(playerid, params[])
{
    new place[256];
    new name [MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if (sscanf(params, "s", place)) UsageMsg(playerid, "Usage: /callmedics <your location>");
    else
    {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(gTeam[i] == TEAM_MEDICS)
        {
            SendFMessage(i,COLOR_SYSTEM,"Player %s needs for medics.",name);
            SendFMessage(i,COLOR_SYSTEM,"Location %s.",place);
            SystemMsg(playerid,"You have called for a medics. Do not move and wait for them.");
        }
    }
    return 1;
}
if I would do
pawn Код:
if(gTeam[i] == TEAM_MEDICS)
        {
            SendFMessage(i,COLOR_SYSTEM,"Player %s needs for medics.",name);
            SendFMessage(i,COLOR_SYSTEM,"Location %s.",place);
            SystemMsg(playerid,"You have called for a medics. Do not move and wait for them.");
        }
        else
        {
        //Send message to player that no medics are connected
        }
It would send message to player if there are at least one player who are NOT in TEAM_MEDICS.. Am I right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)