14.05.2011, 03:10
Ok, first of all, I am not a noob, I know how to use dini. The only problem is, that i am trying to make it, where when u first spawn, u get 400$.
#define StartMoney 400 // Money that player has when he/she spawns
public OnPlayerSpawn(playerid)
{
GivePlayerMoney(playerid, StartMoney);
return 1;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "FirstSpawn", 1); //The player is going to spawn for the first time
return 1;
}
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid, "FirstSpawn")) //If its the first time the player has spawned
{
GivePlayerMoney(playerid, 400);
SetPVarInt(playerid, "FirstSpawn", 0);
}
return 1;
}
#define FirstMoney 400
public OnPlayerConnect(playerid)
{
new name[30],file[256];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"Folder/%s.ini",name);
if(!dini_Exists(file)) {
dini_Create(file);
dini_IntSet(file, "Money", FirstMoney);
SetPVarInt(playerid,"Money",-1);
} else {
new money = dini_Int(file, "Money");
SetPVarInt(playerid,"Money",money);
}
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
new name[30],file[256];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"Folder/%s.ini",name);
if(!dini_Exists(file))
dini_Create(file);
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
return 1;
}
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid,"Money") != -1) {
GivePlayerMoney(playerid,GetPVarInt(playerid,"Money"));
} else {
GivePlayerMoney(playerid,FirstMoney);
}
return 1;
}