Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] [SOLVED] How to detect how many players there are in same place around coordinat

 
  • 0 Vote(s) - 0 Average
Pawn [SOLVED] How to detect how many players there are in same place around coordinat
PutuSuhartawan
Offline

Burgershot Member
Posts: 120
Threads: 52
Joined: Nov 2020
Reputation: 1
Location: Indonesia
#1
2021-05-12, 02:11 AM (This post was last modified: 2021-05-12, 10:13 PM by PutuSuhartawan.)
Solution from Pinch:

Code:
stock returnPlayersInRange(playerid, range = 40.0)
{
    new
        Floatt:x,
        Float:y,
        sloat:z,
        streamed;
       
    GetPlayerPos(playerid, x, y, z);
   
    foreach(new i : Player) {
        if(!IsPlayerInRangeOfPoint(i, range, x, y, z)) {
            continue; // Continue the loop (next slot)
        }
       
        streamed += 1; // Increments the variable by 1
    }
   
    return streamed; // Return the variable's value. 
...or you can just not use this cmd as players can hit F5 or whatever it was and see number of streamed players
}


The problem:
Sir, how do you detect how many players are there? For example, we want to check how many people are in SMB but without checking directly to the location but using cmd, for example cmd / check, there will be a message from the system showing how many people there are. SMB

I think it is necessary first, isplayerinrangeofpoint. Then, the for for the playerid check function has the same enum about them at the same time. enum example. pInfo [playerid] [InZoneName]

is this code can make more extend ?
Code:
new Float:x, Float:y, Float:z;
      GetPlayerPos(playerid, x, y, z);
     
      foreach(new ii : Player)
      {
        if(IsPlayerInRangeOfPoint(ii, 40.0, x, y, z))
        {
          
          {
                     
for(new x;x<MAX_PLAYERS;x++)
    {
       

          }
       
        }
      }
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#2
2021-05-12, 04:12 PM
Code:
stock returnPlayersInRange(playerid, range = 40.0)
{
    new
        Floatt:x,
        Float:y,
        sloat:z,
        streamed;
        
    GetPlayerPos(playerid, x, y, z);
    
    foreach(new i : Player) {
        if(!IsPlayerInRangeOfPoint(i, range, x, y, z)) {
            continue; // Continue the loop (next slot)
        }
        
        streamed += 1; // Increments the variable by 1
    }
    
    return streamed; // Return the variable's value
}

...or you can just not use this cmd as players can hit F5 or whatever it was and see number of streamed players
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
PutuSuhartawan
Offline

Burgershot Member
Posts: 120
Threads: 52
Joined: Nov 2020
Reputation: 1
Location: Indonesia
#3
2021-05-12, 10:04 PM
Thanks, best solution from Pinch
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#4
2021-05-13, 08:54 AM
Just a minor thing. It should be "ReturnPlayersInRange", not "returnPlayersInRange". Or better yet "CountPlayersInRange", since you don't actually get their IDs.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode