How to SetPlayerPos for all the players?
#1

What's the callback to set everyone's position if someone does a command?
Reply
#2

pawn Код:
public OnGameModeInit()
{
    SetGameModeText("TC-MG v 1.2");
    AddPlayerClass(120, 3079.5812988281,-1748.7048339844,1.2784695625305,0, 0, 0, 0, 0, 0, 0);//chinese man 1
    AddPlayerClass(121, 3079.5812988281,-1748.7048339844,1.2784695625305,0, 0, 0, 0, 0, 0, 0);//chinese man 2
    AddPlayerClass(122, 3079.5812988281,-1748.7048339844,1.2784695625305,0, 0, 0, 0, 0, 0, 0);//chinese man 3
return 1;
}
this is an example!

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid,3079.5812988281,-1748.7048339844,1.2784695625305);
    SetPlayerCameraPos(playerid,3079.5812988281,-1748.7048339844,1.2784695625305);
    SetPlayerCameraLookAt(playerid,3079.5812988281,-1748.7048339844,1.2784695625305);
    return 1;
}
and this is for setplayerpos!
Reply
#3

Make a player loop inside the command/function/callback.
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        SetPlayerPos(i, x, y, z);
    }
}
EDIT: I think i misunderstood you.
Reply
#4

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Make a player loop inside the command/function/callback.
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        SetPlayerPos(i, x, y, z);
    }
}
I'm not great at making loops, I'll give it a go.
Reply
#5

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (!
strcmp("/bringall"cmdtexttrue))
    {
        new 
Float:Pos[3],pName[24],string[128];
        
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
        
GetPlayerName(playerid,pName,sizeof(pName));
        
format(string,128,"%s(%d) has brought everyone to his position!",pName,playerid);
        
SendClientMessageToAll(0xFF0000FF,string);
        for(new 
i=0;i<MAX_PLAYERS;i++)
        if(
IsPlayerConnected(i))
        {
            
SetPlayerPos(i,Pos[0],Pos[1],Pos[2]);
            
        }
        return 
1;
    }
    return 
0;

Reply
#6

I did
pawn Код:
COMMAND:aminigame(playerid, cmdtext)
{
    for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        SetPlayerPos(2169.0952,-3170.2466,190);
    }
}
And I get
Quote:

C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\minigame.pwn(491) : warning 213: tag mismatch
C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\minigame.pwn(491) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\minigame.pwn(494) : error 030: compound statement not closed at the end of file (started at line 487)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

I got no idea if I'm doing this correctly
Reply
#7

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (!
strcmp("/bringall"cmdtexttrue))
    {
        new 
Float:Pos[3],pName[24],string[128];
        
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
        
GetPlayerName(playerid,pName,sizeof(pName));
        
format(string,128,"%s(%d) has brought everyone to his position!",pName,playerid);
        
SendClientMessageToAll(0xFF0000FF,string);
        for(new 
i=0;i<MAX_PLAYERS;i++)
        if(
IsPlayerConnected(playerid))
        {
            
SetPlayerPos(i,Pos[0],Pos[1],Pos[2]);
            return 
1;
        }
        return 
1;
    }
    return 
0;

It compiled. I'm about to test it. Can you give me a link where I can learn that? Thank you.
Reply
#8

PHP код:
COMMAND:aminigame(playeridcmdtext)
{
    for(new 
iMAX_PLAYERSi++)
    if(
IsPlayerConnected(i))
    {
        
SetPlayerPos(i,2169.0952,-3170.2466,190.0);
        return 
1;
    }

EDIT: Here
wiki.sa-mp.com/wiki/SetPlayerPos
wiki.sa-mp.com/wiki/GetPlayerPos
wiki.sa-mp.com/wiki/format
https://sampwiki.blast.hk/wiki/Scripting_Basics#Strings
https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables

Those are all things that I have used.
Reply
#9

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (!
strcmp("/bringall"cmdtexttrue))
    {
        new 
Float:Pos[3],pName[24],string[128];
        
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
        
GetPlayerName(playerid,pName,sizeof(pName));
        
format(string,128,"%s(%d) has brought everyone to his position!",pName,playerid);
        
SendClientMessageToAll(0xFF0000FF,string);
        for(new 
i=0;i<MAX_PLAYERS;i++)
        if(
IsPlayerConnected(playerid))
        {
            
SetPlayerPos(i,Pos[0],Pos[1],Pos[2]);
            return 
1;
        }
        return 
1;
    }
    return 
0;

That will fail since as soon as it sets one players position it will return out of the function remove the return from the loop.
Reply
#10

Yeah. I noticed one more thing which I typed wrong
PHP код:
public OnPlayerCommandText(playeridcmdtext[]) 

    if (!
strcmp("/bringall"cmdtexttrue)) 
    { 
        new 
Float:Pos[3],pName[24],string[128]; 
        
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); 
        
GetPlayerName(playerid,pName,sizeof(pName)); 
        
format(string,128,"%s(%d) has brought everyone to his position!",pName,playerid); 
        
SendClientMessageToAll(0xFF0000FF,string); 
        for(new 
i=0;i<MAX_PLAYERS;i++) 
        if(
IsPlayerConnected(i)) 
        { 
            
SetPlayerPos(i,Pos[0],Pos[1],Pos[2]); 
             
        } 
        return 
1
    } 
    return 
0

It's good now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)