SA-MP Forums Archive
if(FewPlayersIsInArea) :P how to do it - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: if(FewPlayersIsInArea) :P how to do it (/showthread.php?tid=531049)



if(FewPlayersIsInArea) :P how to do it - Lirbo - 10.08.2014

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")


Re: if(FewPlayersIsInArea) :P how to do it - [XST]O_x - 10.08.2014

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;
}



Re: if(FewPlayersIsInArea) :P how to do it - Faisal_khan - 10.08.2014

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



Re: if(FewPlayersIsInArea) :P how to do it - Lirbo - 10.08.2014

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}



Re: if(FewPlayersIsInArea) :P how to do it - [XST]O_x - 10.08.2014

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;
}



Re: if(FewPlayersIsInArea) :P how to do it - Mauzen - 10.08.2014

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.