Saving Player Pos and Loading it.
#1

Hey can anyone create me a FS or script when player leaves server somewhere and joins back he will spawn where he was last. I am trying to create it for a hour now and i cant error all the times.
Reply
#2

Make a players directory in scriptfiles

PHP код:
#include <a_samp>
public OnPlayerConnect(playerid)
{
    new 
str[128], idx 0;
    
GetPlayerName(playeridstrsizeof(str));
    
format(strsizeof(str), "players/%s.txt"str);
    if(
fexist(str))
    {
        new 
File:ftw fopen(strio_read);
        if(
ftw)
        {
            new 
Float:floatstr(strtok(stridx));
        new 
Float:floatstr(strtok(stridx));
            new 
Float:floatstr(strtok(stridx));
            new 
Float:floatstr(strtok(stridx));
            
SetPlayerPos(playeridXYZ);
            
SetPlayerFacingAngle(playeridA);
        }
    
fclose(ftw);
    }
    return 
1;
}
public 
OnPlayerDisconnect(playerid)
{
    new 
str[128], Float:XFloat:YFloat:ZFloat:A;
    
GetPlayerName(playeridstrsizeof(str));
    
GetPlayerPos(playeridXYZ);
    
GetPlayerFacingAngle(playeridA);
    
format(strsizeof(str), "players/%s.txt"str);
    new 
File:ftw fopen(strio_write);
    if(
ftw)
    {
    
format(strsizeof(str), "%.2f %.2f %.2f %.2f"XYZA);
        
fwrite(ftwstr);
    }
    
fclose(ftw);
    return 
1;
}
stock strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result[128];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

Reply
#3

You can find mysql and y_ini versions in my signature.
Reply
#4

Have that here it is in PT and uses dini, if you use DOF2 or another and only convert ..

Tуpic: www.forum.sa-mp.com/showthread.php?t=191533

Download: http://www.solidfiles.com/d/6765c/FS...Coordenada.zip
Reply
#5

Quote:
Originally Posted by reiss82
Посмотреть сообщение
Make a players directory in scriptfiles

PHP код:
#include <a_samp>
public OnPlayerConnect(playerid)
{
    new 
str[128], idx 0;
    
GetPlayerName(playeridstrsizeof(str));
    
format(strsizeof(str), "players/%s.txt"str);
    if(
fexist(str))
    {
        new 
File:ftw fopen(strio_read);
        if(
ftw)
        {
            new 
Float:floatstr(strtok(stridx));
        new 
Float:floatstr(strtok(stridx));
            new 
Float:floatstr(strtok(stridx));
            new 
Float:floatstr(strtok(stridx));
            
SetPlayerPos(playeridXYZ);
            
SetPlayerFacingAngle(playeridA);
        }
    
fclose(ftw);
    }
    return 
1;
}
public 
OnPlayerDisconnect(playerid)
{
    new 
str[128], Float:XFloat:YFloat:ZFloat:A;
    
GetPlayerName(playeridstrsizeof(str));
    
GetPlayerPos(playeridXYZ);
    
GetPlayerFacingAngle(playeridA);
    
format(strsizeof(str), "players/%s.txt"str);
    new 
File:ftw fopen(strio_write);
    if(
ftw)
    {
    
format(strsizeof(str), "%.2f %.2f %.2f %.2f"XYZA);
        
fwrite(ftwstr);
    }
    
fclose(ftw);
    return 
1;
}
stock strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result[128];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)