if(FewPlayersIsInArea) :P how to do it
#1

I want to make command if at least 4 people from the same clan in area its will start to flash the gangzone (i know how to flash gangzone)

my function to get player's clan is
DOF2_GetString(pFile(playerid),"Clan")
Reply
#2

pawn Код:
stock GetPlayersInArea(Float: x, Float: y, Float: z, clan[], Float: radius)
{
    new count = 0;
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, radius, x, y, z) && !strcmp(clan, DOF2_GetString(pFile(i),"Clan")) count++;
    }
    return count;
}

public someCallback(someParameters)
{
    if(GetPlayersInArea(x, y, z, "ExampleClan", 45.0) >= 4) StartFlashingGZone(gzoneid);
    return somevalue;
}
Reply
#3

This?
pawn Код:
new count = 0;
for(new i=0; i<=MAXPLAYERS; i++)
{
    if(IsPlayerInArea() count++;
    if((IsPlayerInArea() && count >= 2)
    {
      //Do something
        }
      return 1;
    }
}
Reply
#4

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
pawn Код:
stock GetPlayersInArea(Float: x, Float: y, Float: z, clan[], Float: radius)
{
    new count = 0;
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, radius, x, y, z) && !strcmp(clan, DOF2_GetString(pFile(i),"Clan")) count++;
    }
    return count;
}

public someCallback(someParameters)
{
    if(GetPlayersInArea(x, y, z, "ExampleClan", 45.0) >= 4) StartFlashingGZone(gzoneid);
    return somevalue;
}
can i do it with my stock?
pawn Код:
stock IsPlayerInArea(playerid,Float:min_x,Float:min_y,Float:max_x,Float:max_y)
{
 new Float: p[3];
 GetPlayerPos(playerid,p[0],p[1],p[2]);
 return p[0] >= min_x && p[0] <= max_x && p[1] >= min_y && p[1] <= max_y? 1:0;
}
i need the stock will do this function:

pawn Код:
if(IsClanInArea(min_x,min_y,max_x,max_y,ClanName,NumberOfPeopleInTheArea)){blah blah blah}
Reply
#5

pawn Код:
stock GetPlayersInArea(Float:min_x,Float:min_y,Float:max_x,Float:max_y, clan[])
{
    new count = 0;
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInArea(i, min_x, min_y, max_x, max_y) && !strcmp(clan, DOF2_GetString(pFile(i),"Clan")) count++;
    }
    return count;
}

public someCallback(someParameters)
{
    if(GetPlayersInArea(10.5, 13.5, 150.0, 120.0, "ExampleClan") >= 4) StartFlashingGZone(gzoneid);
    return somevalue;
}
Reply
#6

You should read the clan directly from the userfiles, but save it in some variable when the player joins. Else that check will be slow as hell and you cant use it properly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)