Problem: Saving Player Position
#1

Hi guys,

I have made a filterscript called SavePos and everything works fine excepted of that the player spawns the first time random at the world. I don't know how I can make that the player spawns at this coordinates: 2229.0200,-1159.7896,25.7981,90.0000 at the first time. Please help me.

This is my script:

PHP код:
#include <a_samp>
#include <dini>
public OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" SavePos Filterscript");
    print(
"--------------------------------------\n");
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
file[128], pname[MAX_PLAYER_NAME];
    new 
Float:xFloat:yFloat:z;
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(filesizeof(file), "\\SavePos\\%s.ini"pname);
    if(!
dini_Exists(file))
    
dini_Create(file);
    
GetPlayerPos(playeridxyz);
    
dini_FloatSet(file"posX"x);
    
dini_FloatSet(file"posY"y);
    
dini_FloatSet(file"posZ"z);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    new 
file[128], pname[MAX_PLAYER_NAME];
    new 
Float:xFloat:yFloat:z;
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(filesizeof(file), "\\SavePos\\%s.ini"pname);
    
dini_Float(file"posX");
    
dini_Float(file"posY");
    
dini_Float(file"posZ");
    
SetPlayerPos(playeridxyz);
    return 
1;

Reply
#2

well when they spawn check if x=0.0,y=0.0,z=0.0

if they do then set their position to your cords 2229.0200,-1159.7896,25.7981,90.0000
if their not = 0.0 then use the x,y,z

something like

pawn Код:
x = dini_Float(file, "posX");
    y = dini_Float(file, "posY");
    z = dini_Float(file, "posZ");
    if (x==0.0 && y==0.0 && x==0.0)
    {
        SetPlayerPos(playerid, 2229.0200,-1159.7896,25.7981,90.0000);
    }
    else
    {
        SetPlayerPos(playerid, x, y, z);
    }
Reply
#3

pawn Код:
SetPlayerPostionOnSpawn: {Playerid}{2229.0200,-1159.7896,25.7981,90.0000};
Reply
#4

Quote:
Originally Posted by rachit_rocks
Посмотреть сообщение
pawn Код:
SetPlayerPostionOnSpawn: {Playerid}{2229.0200,-1159.7896,25.7981,90.0000};
thats not even a function in samp!!! and you could never call a function with that syntax.,
(atleast not without some fancy marco)
you need to re-read the topic if your gonna try to help,
Reply
#5

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
thats not even a function in samp!!! and you could never call a function with that syntax.,
(atleast not without some fancy marco)
you need to re-read the topic if your gonna try to help,
Dude it's because he only said this coordinates.That's a mistake.
Reply
#6

It worked! Thank you guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)