Saving Player Pos and Loading it.
#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


Messages In This Thread
Saving Player Pos and Loading it. - by GreenSt4lker - 27.07.2014, 16:37
Re: Saving Player Pos and Loading it. - by reiss82 - 27.07.2014, 16:47
Re: Saving Player Pos and Loading it. - by Wizzy951 - 27.07.2014, 16:49
Re: Saving Player Pos and Loading it. - by Ts3 - 27.07.2014, 16:54
Re: Saving Player Pos and Loading it. - by GreenSt4lker - 27.07.2014, 17:22

Forum Jump:


Users browsing this thread: 4 Guest(s)