Look the comments.
pawn Code:
public OnPlayerConnect(playerid)
{
new
pName[MAX_PLAYER_NAME],
file[64];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "Players/%s.ini", pName);
if(!dini_Exists(file))
{
//if it doesn't exist it MUST be created.
dini_Create(file);
gTeam[playerid] = TEAM_CIV;
new Float:x;
new Float:y;
new Float:z;
GetPlayerPos(playerid,x,y,z);
skin = GetPlayerSkin(playerid);
positionx = x;
positiony = y;
positionz = z;
dini_IntSet(file, "Teams", gTeam[playerid]);
dini_IntSet(file, "Wanted",wanted);
dini_IntSet(file, "PositionX", floatround(positionx));
dini_IntSet(file, "PositionY", floatround(positiony));
dini_IntSet(file, "PositionZ", floatround(positionz));
//WHY floatround? It SHOULD be a FLOAT.
dini_IntSet(file, "Skin", skin);
}
else
{
gTeam[playerid] = dini_Int(file, "Teams");
wanted = dini_Int(file, "Wanted");
positionx = dini_Int(file, "PositionX");
positiony = dini_Int(file, "PositionY");
positionz = dini_Int(file, "PositionZ");
skin = dini_Int(file, "skin");
}
// wanted, positionx, positiony, positionz, skin MUST be an array like gTeam[playerid]!!!
}
public OnPlayerDisconnect(playerid, reason)
{
new Float:x;
new Float:y;
new Float:z;
GetPlayerPos(playerid,x,y,z);
skin = GetPlayerSkin(playerid);
positionx = x;
positiony = y;
positionz = z;
wanted = GetPlayerWantedLevel(playerid);
new pName[MAX_PLAYER_NAME], file[64];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "Players/%s.ini", pName);
if(!dini_Exists(file)){ dini_Create(file); }
dini_IntSet(file, "Teams", gTeam[playerid]);
dini_IntSet(file, "Wanted",wanted);
dini_IntSet(file, "PositionX", floatround(positionx));
dini_IntSet(file, "PositionY", floatround(positiony));
dini_IntSet(file, "PositionZ", floatround(positionz));
//WHY floatround? It SHOULD be a FLOAT.
dini_IntSet(file, "Skin", skin);
// wanted, positionx, positiony, positionz, skin MUST be an array like gTeam[playerid]!!!
return 1;
}
public OnPlayerSpawn(playerid)
{
new pName[MAX_PLAYER_NAME], file[64];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(file, sizeof(file), "Players/%s.ini", pName);
if(!dini_Exists(file))
{
dini_Create(file);//Create the file
SetPlayerPos(playerid,1647.1093,-2308.5242,14.5156);
}
else
{
SetPlayerPos(playerid, positionx,positiony,positionz);
SetPlayerSkin(playerid, skin);
// positionx, positiony, positionz, skin MUST be an array like gTeam[playerid]!!!
}
return 1;
}