SA-MP Forums Archive
Pos for all - 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: Pos for all (/showthread.php?tid=596373)



Pos for all - suni - 16.12.2015

Hey can someone show me a example of how to create a command like /makepos to save a position and /gotopos for all players to teleport to that place?

I removed the codes i created earlier so i can't post them here.(: i once make a saving position command work well but when the player use a command to teleport to that position i saved they teleport somewhere else.


Re: Pos for all - prineside - 16.12.2015

If I understood right:
PHP код:
new Float:savedPosition[3]; // We'll store the position here

CMD:makepos(playeridargs) {
    
GetPlayerPosplayeridsavedPosition[0], savedPosition[1], savedPosition[2] );
    
SendClientMessageplayerid, -1"Position was saved" );
}

CMD:gotopos(playeridargs) {
    
SetPlayerPosplayeridsavedPosition[0], savedPosition[1], savedPosition[2] );
    
SendClientMessageplayerid, -1"You were teleported" );




Re: Pos for all - malackov - 16.12.2015

PHP код:
CMD:makepos(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
Float:pos[3];
        
GetPlayerPos(playeridpos[0],pos[1],pos[2]);
        
pInfo[playerid][posX] = pos[0];
          
pInfo[playerid][posY] = pos[1];
          
pInfo[playerid][posZ] = pos[2];
    }
    else
    {
        
SendClientMessage(playerid1" (( You have to be a rcon admin to do this )) ");
    }
    return 
1;
}
CMD:gotopos(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
        for(new 
0MAX_PLAYERSi++)
        {
            
SetPlayerPos(i,pInfo[playerid][posX],pInfo[playerid][posY],pInfo[playerid][posZ]);
        }
    }
    else
    {
        
SendClientMessage(playerid1" (( You have to be a rcon admin to do this )) ");
    }
    return 
1;

you could try this ( didn't test this ), but add on the top of the page
PHP код:
enum PlayerData {
    
Float:posX,
    
Float:posY,
    
Float:posZ
}
new 
pInfo[MAX_PLAYERS][PlayerData]; 



Re: Pos for all - suni - 16.12.2015

Thanks all +rep.