Saving Players
#1

Hey,

I was wondering if this stock function would save the player correctly or just ruin the file
pawn Код:
stock SavePlayer(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    new name[MAX_PLAYER_NAME];
    INI_SetTag(File,"Account Info");
    INI_WriteInt(File,"Username",GetPlayerName(playerid,name,MAX_PLAYER_NAME));
    INI_WriteInt(File,"Password",udb_hash(inputtext));
    INI_WriteInt(File,"Administrator",0);
    INI_WriteInt(File,"Donator",0);
    INI_SetTag(File,"Banned Info");
    INI_WriteInt(File,"Cheater",0);
    INI_WriteInt(File,"Banned",0);
    INI_WriteInt(File,"Muted",0);
    INI_SetTag(File,"Other Info");
    INI_WriteInt(File,"Times Robbed",0);
    INI_WriteInt(File,"Robbed",0);
    INI_WriteInt(File,"Wanted Levels Gained",0);
    INI_WriteInt(File,"Kills",0);
    INI_WriteInt(File,"Deaths",0);
    INI_WriteInt(File,"Score",0);
    INI_WriteInt(File,"Cash",15000);
    INI_SetTag(File,"Float Info");
    INI_WriteFloat(File,"Armour",0);
    INI_WriteFloat(File,"Health",100);
    INI_Close(File);
}
Basically i need it to update the players file, this is so if the player crashes it will stop the loss of information so much.

Thanks
Reply
#2

this is what my save function look like using ini

PHP код:
public SavePlayerData(playeridname[]) <players:on>
{
    new 
string[128];
    
format(string,256,"Players/%s.txt",name);
    new 
INI:acc INI_Open(string);
    
INI_WriteString(acc"PASSWORD"Passwords[playerid]);
    
INI_WriteFloat(acc"PLAYER_HEALTH"gPlayerData[playerid][HEALTH]);
    
INI_WriteInt(acc"PLAYER_MONEY"gPlayerData[playerid][PLAYER_MONEY]);
    
INI_WriteFloat(acc"POSX"spawnx);
    
INI_WriteFloat(acc"POSY"spawny);
    
INI_WriteFloat(acc"POSZ"spawnz);
    
INI_WriteFloat(acc"ROTZ"spawnzr);
    
INI_WriteInt(acc"SKIN"gPlayerData[playerid][PLAYER_SKIN]);
    
INI_WriteInt(acc"DEATHS"gPlayerData[playerid][DEATHS]);
    
INI_WriteInt(acc"ADMINLEVEL"gPlayerData[playerid][ADMINLEVEL]);
    
INI_WriteInt(acc"VIPLEVEL"gPlayerData[playerid][VIPLEVEL]);
    
INI_WriteInt(acc"VIRTUAL-WORLD"gPlayerData[playerid][VIRTUALWORLD]);
    
INI_WriteInt(acc"INTERIOR"gPlayerData[playerid][INTERIOR]);
    
INI_WriteInt(acc"VIP"gPlayerData[playerid][VIP]);
    
INI_Close(acc); // Close the file
    
return 1;

Reply
#3

Just use the save function in 'OnPlayerDisconnect' to update the file...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)