13.10.2010, 20:17
Basically I followed a tutorial found on this forums.
The values I got is;
- AdminLevel
- PlayerSkin
- PlayerMoney
- PlayerScore
For some reason it's only the Adminlevel that fully works.
Money NEVER save.
Skins save on re-log, but not on server restart.
------------------------------------------
----------------
------------------
---------------------
Anyone see the problem? I sure don't.
This is the CMD I use for changing someones skin.
The values I got is;
- AdminLevel
- PlayerSkin
- PlayerMoney
- PlayerScore
For some reason it's only the Adminlevel that fully works.
Money NEVER save.
Skins save on re-log, but not on server restart.
------------------------------------------
pawn Код:
new logged[MAX_PLAYERS];
enum pInfo
{
AdminLevel,
PlayerMoney,
PlayerScore,
PlayerSkin,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"/Users/%s.ini",name);
if(dini_Exists(file))
{
dini_IntSet(file, "PlayerScore", PlayerInfo[playerid][PlayerScore]);
dini_IntSet(file, "PlayerMoney", PlayerInfo[playerid][PlayerMoney]);
dini_IntSet(file, "PlayerSkin", PlayerInfo[playerid][PlayerSkin]);
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel]);
}
logged[playerid] = 0;
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"[Join/Quit] %s has left the server.",pName);
SendClientMessageToAll(color_grey,string);
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
new file[128];
SetPlayerPos(playerid, spawnpoint);
SetPlayerMoney(playerid, dini_Int(file, "PlayerMoney")-GetPlayerMoney(playerid));
SetPlayerScore(playerid, PlayerInfo[playerid][PlayerScore]);
SetPlayerSkin(playerid, PlayerInfo[playerid][PlayerSkin]);
SetPlayerColor(playerid, color_white);
return 1;
}
pawn Код:
dcmd_register(playerid, params[])
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\Users\\%s.ini", pname);
if(!strlen(params)) return SendClientMessage(playerid, color_white, "Hint: Use /register [password] to register your character.");
if(dini_Exists(file)) return SendClientMessage(playerid, color_white, "Hint: You are already registered. If this is your account, use /login.");
dini_Create(file);
dini_IntSet(file, "hashPW", udb_hash(params));
dini_Set(file, "password", params);
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0);
dini_IntSet(file, "PlayerScore", PlayerInfo[playerid][PlayerScore] = 0);
dini_IntSet(file, "PlayerMoney", PlayerInfo[playerid][PlayerMoney] = 500);
dini_IntSet(file, "PlayerSkin", PlayerInfo[playerid][PlayerSkin] = 60);
new string[128];
format(string, 128, "Hint: You succesfully registered the nickname %s with password %s.", pname, params);
SendClientMessage(playerid, color_green, string);
logged[playerid] = 1;
SendClientMessage(playerid, color_green, "Hint: You have been automatically logged in!");
SpawnPlayer(playerid);
printf("*** USER REGISTERED :: USERNAME: %s || PASSWORD: %s ***", pname, params);
return 1;
}
pawn Код:
dcmd_login(playerid, params[])
{
new file[128];
new string[MAX_STRING], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\Users\\%s.ini", pname);
if(!strlen(params)) return SendClientMessage(playerid, color_white, "Hint: Use /login [password] to log into your character account.");
if(!dini_Exists(file)) return SendClientMessage(playerid, color_white, "Hint: You are not registered, use /register to register a new account.");
if(logged[playerid]) return SendClientMessage(playerid, color_white, "Hint: You are already logged in.");
new tmp;
tmp = dini_Int(file, "hashPW");
if(udb_hash(params) != tmp)
{
format(string, 256, "Error: Wrong password for username: %s.", pname);
SendClientMessage(playerid, color_red, string);
}
else
{
TogglePlayerSpectating(playerid, 0);
logged[playerid] = 1;
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
format(string, 256, "Hint: Successfully logged into account: %s.", pname);
SendClientMessage(playerid,color_green, string);
SpawnPlayer(playerid);
printf("*** USER LOGGED IN :: USERNAME: %s || ID: (%i) || PASSWORD: %s ***", pname, playerid, params);
}
return 1;
}
This is the CMD I use for changing someones skin.
pawn Код:
dcmd_setskin(playerid, params[])
{
new id, pskin, pname[MAX_PLAYER_NAME];
new file[128];
new string[128];
if(PlayerInfo[playerid][AdminLevel] <2) return SendClientMessage(playerid, color_red, "* You do not have access to execute this command.");
if(sscanf(params, "ud", id, pskin)) return SendClientMessage(playerid, color_yellow, "* AdmHint: Usage /setskin [id] [skin id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, color_red, "Hint: Player is not connected.");
SetPlayerSkin(id, pskin);
pskin = GetPlayerSkin(id);
dini_IntSet(file, "PlayerSkin",PlayerInfo[playerid][PlayerSkin] = pskin);
GetPlayerName(id, pname, MAX_PLAYER_NAME);
format(string, sizeof(string), "* AdmHint: You changed %s's skin to skinID: %d.", pname, pskin);
SendClientMessage(playerid, color_yellow, string);
return 1;
}