if is a EMS?
#1

Hello guys. I am working on to fix like, if no EMS is on duty /accept death will work. If EMS is on duty /accept death wont work. I think you understand. Anyways, because I am new and very noob in PAWN I will need some help.. To start off, how to create a code that checks for EMS?

its like
pawn Код:
if(EMSOnline, playerid) SendClientMessage ("You cant accept death when EMS is available");
Anyways, I think you understand me... How can help me? It would make me very happy
Reply
#2

what is your variable to say whether some EMS is on duty?...
I'll just use "EMS[playerid] = 1" for "on duty" now, you might need to change it later, or tell me what the actual variable is (or if you don't know, show me the command that makes a player go "on duty").

you can use a function like that:
pawn Код:
stock EMSOnline()
{
    new dutycount = 0;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerOnline(i))
        {
            if(EMS[i] == 1)
            {
                dutycount++;
            }
        }
    }
    if(dutycount > 0)
    {
        return 1;
    }
    return 0;
}
at on your command
pawn Код:
if(EMSOnline) SendClientMessage ("You cant accept death when EMS is available");
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
what is your variable to say whether some EMS is on duty?...
I'll just use "EMS[playerid] = 1" for "on duty" now, you might need to change it later, or tell me what the actual variable is (or if you don't know, show me the command that makes a player go "on duty").

you can use a function like that:
pawn Код:
stock EMSOnline()
{
    new dutycount = 0;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerOnline(i))
        {
            if(EMS[i] == 1)
            {
                dutycount++;
            }
        }
    }
    if(dutycount > 0)
    {
        return 1;
    }
    return 0;
}
at on your command
pawn Код:
if(EMSOnline) SendClientMessage ("You cant accept death when EMS is available");
Thanks for fast respons. anyways. For a EMS member to go on duty he uses /badge OR /lsfmd and --> Duty..
I will try your code
Reply
#4

Quote:
Originally Posted by Sascha
Посмотреть сообщение
what is your variable to say whether some EMS is on duty?...
I'll just use "EMS[playerid] = 1" for "on duty" now, you might need to change it later, or tell me what the actual variable is (or if you don't know, show me the command that makes a player go "on duty").

you can use a function like that:
pawn Код:
stock EMSOnline()
{
    new dutycount = 0;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerOnline(i))
        {
            if(EMS[i] == 1)
            {
                dutycount++;
            }
        }
    }
    if(dutycount > 0)
    {
        return 1;
    }
    return 0;
}
at on your command
pawn Код:
if(EMSOnline) SendClientMessage ("You cant accept death when EMS is available");
this is the command for all the factions
pawn Код:
CMD:badge(playerid, params[]) {
    if((IsACop(playerid) || PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4 || PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12) && GetPVarInt(playerid, "IsInArena") < 0 && !GetPVarInt(playerid, "EventToken") && PlayerInfo[playerid][pJailed] == 0 || PlayerInfo[playerid][pMember] == 9 && PlayerInfo[playerid][pDivision] == 1) {
        if(PlayerInfo[playerid][pDuty]) {
            PlayerInfo[playerid][pDuty] = 0;
            SetPlayerToTeamColor(playerid);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have hidden your badge, and will now be identified as being off-duty.");
        }
        else {
            PlayerInfo[playerid][pDuty] = 1;
            SetPlayerToTeamColor(playerid);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have shown your badge, and will now be identified as being on-duty.");
        }
    }
    return 1;
}
Reply
#5

then you have to change my code to this:
pawn Код:
stock EMSOnline()
{
    new dutycount = 0;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerOnline(i))
        {
            if(PlayerInfo[i][pDuty] == 1)
            {
                dutycount++;
            }
        }
    }
    if(dutycount > 0)
    {
        return 1;
    }
    return 0;
}
this way it should work with your variables
Reply
#6

Thanks bro
Reply
#7

well that command with if(EMSOnline) dont work.. What should I do instead?
Reply
#8

try it with "if(EMSOnline())"
oh and ofc change "IsPlayerOnline" to "IsPlayerConnected"

pawn Код:
stock EMSOnline()
{
    new dutycount = 0;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pDuty] == 1)
            {
                dutycount++;
            }
        }
    }
    if(dutycount > 0)
    {
        return 1;
    }
    return 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(EMSOnline()) return SendClientMessage(playerid, 0xFFFFFFAA, "Whatever");
        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)