08.01.2012, 19:32
i need some help with the money saving when a player connects/disconnects please pm me with some help im using Y/INI.
#include <dini>
public OnPlayerConnect(playerid)
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid,aname,sizeof(aname));
if(dini_Exists("aname.ini"))
{
SendClientMessage(playerid,-1,"[x] Logue-se para carregar sua conta...");
}
else if(!dini_Exists("aname.ini"))
{
dini_Create("aname.ini");
dini_IntSet("aname.ini", "Dinheiro", 0);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid,aname,sizeof(aname));
dini_IntSet("aname.ini","Dinheiro",GetPlayerMoney(playerid));
return 1;
}
public OnPlayerSpawn(playerid)
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid,aname,sizeof(aname));
GivePlayerMoney(playerid,dini_Int("aname.ini","Dinheiro"));
return 1;
}
Meus Projetos¤ GameModes ¤Brasil City Virtual 0.3e ---- 40 % Completed »» Forum: BcvGames.forumbrasil.net »» Site: Gta Lokidoido »» Servidor: [0.3e] • Brasil City Virtual • [RPG v1.0] »» Equipe: Murilo / dPlaYer / Malakas / Bruno_. e Emerson_.
pawn Код:
Код:
|
#include <YSI\y_ini>
#define UserPath "Users/%s.ini"
enum PlayerInfo
{
Money, //User's money
}
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
forward loadaccount_user(playerid, name[], value[]); //forwarding a new function to load user's data
//Now we will use our own function that we have created above
public loadaccount_user(playerid, name[], value[])
{
INI_Int("Money",pInfo[playerid][Money]); //As explained above
return 1;
}
public OnPlayerConnect(playerid)
{
GivePlayerMoney(playerid,pInfo[playerid][Money]);
return 1;
}
public OnPlayerDisconnect(playerid)
{
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
return 1;
}