Getting players position
#1

Hello guys is it possible getting all connected players position and then creating explosion for each player? if so how i can do that i know the explosion part just need someone to teach me getting everyones X Y Z
Reply
#2

PHP код:
for(new 0MAX_PLAYERSi++) //loop
{
   if(
IsPlayerConnected(i)) //Check if is Player Connected
   
{
      new 
Float:xFloat:yFloat:z;  //variables
      // Use GetPlayerPos, passing the 3 float variables we just created
      
GetPlayerPos(playeridxyz);
      
CreateExplosion(xyz1210.0); //Create explosion on x, y, z cords
   
}
   return 
1;

Reply
#3

Код:
COMMAND:explode(playerid, params[])
{
        new bombid;
		new fstr[200];
        if (PlayerInfo[playerid][admin variable] < 0 || IsPlayerAdmin(playerid)) // change the admin variable to yours
   

        if(sscanf(params, "u", bombid)) return SendClientMessage(playerid, COLOR_ERROR, "[USAGE]: /explode [name/id]");
        if(!IsPlayerConnected(bombid)) return SendClientMessage(playerid, COLOR_ERROR, "Player not found.");
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(bombid,x,y,z);
            CreateExplosion(x,y,z,6,5);
            CreateExplosion(x+2.5,y,z,6,2.5);
            CreateExplosion(x,y+2.5,z,6,2.5);
            CreateExplosion(x,y,z+2.5,6,2.5);
            SetPlayerHealth(bombid, 0.0);
            format(fstr, sizeof(fstr), "%s (%d) Died. (Unspecified Explosion)", PlayerInfo[bombid][pName], bombid);
            SendClientMessageToAll(-1, fstr);
            SendClientMessage(bombid, -1, "An Admin Exploded You");

        }else{
			SendClientMessage(playerid,COLOR_ERROR,"Unknown Command! type /cmds to see all available commands");
	}
    return 1;
}
This will make sure the player dies :P

dependencies:
zcmd
sscanf.

Edit: i misunderstood, Red_Hunter's solution is right, you want to get each player position and wana explode them, yes for loop it is.
Reply
#4

i did this code it should send a warning message every 10 seconds and save player position and after 20 seconds there should be an explosion in the save x y z position of player

but i am not gettibg warning message and the explosion happen on my player even if i leave the old position where i get a warning.

this is my code

PHP код:
// at the to
new Float:Pos[3][MAX_PLAYERS];
// gamemodeint
    
SetTimer("Airstrikemsg"100001); 
PHP код:
public Airstrikemsg()
{
    
SendClientMessageToAll(-1"clear your position airstike coming!");
    for(new 
i=0;i<MAX_PLAYERS;i++)
    if(
IsPlayerConnected(i))
    {
        
GetPlayerPos(i,Pos[0][i],Pos[1][i],Pos[2][i]);
    }
    
SetTimer("Airstrikestart"200001);
    return 
1;
}
public 
Airstrikestart(playerid)
{
    
CreateExplosion(Pos[0][playerid], Pos[1][playerid], Pos[2][playerid], 71000.0);
    return 
1;

Reply
#5

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
PHP код:
for(new 0MAX_PLAYERSi++) //loop
{
   if(
IsPlayerConnected(i)) //Check if is Player Connected
   
{
      new 
Float:xFloat:yFloat:z;  //variables
      // Use GetPlayerPos, passing the 3 float variables we just created
      
GetPlayerPos(playeridxyz);
      
CreateExplosion(xyz1210.0); //Create explosion on x, y, z cords
   
}
   return 
1;

Slightly shorter version; IsPlayerConnected can be avoided in many, many situations. Also you had a return in the loop (force of habbit, I guess?).

PHP код:
for(new 0Float:xFloat:yFloat:zMAX_PLAYERSi++) //loop
{
   if(
GetPlayerPos(ixyz)) //Check if is Player Connected
   
{
      
CreateExplosion(xyz1210.0); //Create explosion on x, y, z cords
   
}

Reply
#6

SetTimer("Airstrikestart", 20000, 0);
Reply
#7

pawn Код:
new Float:x, Float:y, Float:z;
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
{
    if(!IsPlayerConnected(i)) continue;

    GetPlayerPos(i, x, y, z);
    CreateExplosion(x, y, z, 12, 10.0);
}
Reply
#8

did u tried what i told you?
Reply
#9

Quote:
Originally Posted by Vince
Посмотреть сообщение
Slightly shorter version; IsPlayerConnected can be avoided in many, many situations. Also you had a return in the loop (force of habbit, I guess?).

PHP код:
for(new 0Float:xFloat:yFloat:zMAX_PLAYERSi++) //loop
{
   if(
GetPlayerPos(ixyz)) //Check if is Player Connected
   
{
      
CreateExplosion(xyz1210.0); //Create explosion on x, y, z cords
   
}

Quote:
Originally Posted by MeCom
Посмотреть сообщение
SetTimer("Airstrikestart", 20000, 0);
Quote:
Originally Posted by Kevln
Посмотреть сообщение
pawn Код:
new Float:x, Float:y, Float:z;
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
{
    if(!IsPlayerConnected(i)) continue;

    GetPlayerPos(i, x, y, z);
    CreateExplosion(x, y, z, 12, 10.0);
}
Quote:
Originally Posted by MeCom
Посмотреть сообщение
did u tried what i told you?
https://sampforum.blast.hk/showthread.php?tid=594022
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)