Multiple Player Function ?
#1

So basically what I wanna do is make a function which can detect if players minimum 4 are in range of a point , if they are I want 4 players to be given a var like example there are four players near a point I want them after typing a command that the server should send a message you 4 are selected players and this should be send only to those 4 players and no one else. So I want a function that detects if 4 players are near a point and if they are another function which sends message only to those 4 players. I tried to make it but Instead I was one only then too it send me 4 messages , if there are less than 4 people it shall say you need at least 4 players !
Reply
#2

You want the coding or explination, cuz im on my phone, so cant do coding.
Reply
#3

This can work:
pawn Код:
CMD:yourcommand(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
        return 0;

    new pInZone = 0;
    new playerIDs[ 20 ];

    foreach(new i: Player)
    {
        if(IsPlayerInRangeOfPoint(i, Float:range, Float:x, Float:y, Float:z)) {
            playerIDs[pInZone] = i;
            pInZone++;
        }
    }

    if(pInZone < 4)
        return SendClientMessage(playerid, -1, "There must be at least 4 players in the range!");

    foreach(new j : Player)
    {
        for(new i = 0; i < 20; i++)
        {
            if(j == playerIDs[i])
                SendClientMessage(j, "You are one of the players in the zone!");
        }
    }

    return 1;
}
Reply
#4

Also now from that I want the selected players ( 4 Players ) to be p1 , p2 , p3 , p4 . Like If I SendClientMessage to p2 the message should go to only p2 and not anyone else. How shall I do that ?
Also I just want 4 players to be selected , Like if there are more than 4 it must give back You need only 4 Players , no more than four
Reply
#5

Two player loops [XST]O_x? No.

pawn Код:
CMD:yourcommand(playerid, params[])
{
    new pInZone = 0, playerIDs[4];

    foreach(new i : Player)
    {
        if(pInZone >= sizeof(playerIDs)) break;
        if(IsPlayerInRangeOfPoint(i, range, x, y, z))
            playerIDs[pInZone++] = i;
    }
    if(pInZone != 4) return SendClientMessage(playerid, -1, (pInZone > 4) ? ("You can only have up to 4 players in range.") : ("You must have 4 players in range."));

    for(new i = 0; i < pInZone; i++)
    {
        SendClientMessage(playerIDs[i], -1, "You are one of the players in the zone!");
    }
    return 1;
}
Player 1 = playerIDs[0].
Player 2 = playerIDs[1].
etc.

Are you being lazy, or do you seriously not know how to check if a value is bigger or smaller than 4? There is a wiki for a reason, I mean... come on...
Reply
#6

Now I wasn't lazy I was just annoyed as I put a lot time to make something like that , BTW Thanks a Lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)