30.08.2011, 23:38
pawn Код:
new Conta[MAX_PLAYERS][DATA];
enum Data
{
Float:saved_armour,
Float:saved_health,
Float:saved_X,
Float:saved_Y,
Float:saved_Z,
Float:saved_ang,
saved_int
}
OnPlayerCommandText
{
if (strcmp(cmd, "/x1", true) == 0)
{
SavePlayerData(playerid);
}
if (strcmp(cmd, "/sair", true) == 0)
{
LoadPlayerData(playerid);
}
}
forward public SavePlayerData(playerid);
public SavePlayerData(playerid)
{
new Float: health, Float: armour, Float: SX, Float: SY, Float: SZ, Float:ang;
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
GetPlayerPos(playerid, SX, SY, SZ);
GetPlayerFacingAngle(playerid, ang);
//
Conta[playerid][saved_money] = GetPlayerMoney(playerid);
Conta[playerid][saved_skin] = GetPlayerSkin(playerid);
Conta[playerid][saved_health] = health;
if (armour > 0) Conta[playerid][saved_armour] = armour;
Conta[playerid][saved_X] = SX;
Conta[playerid][saved_Y] = SY;
Conta[playerid][saved_Z] = SZ;
Conta[playerid][saved_ang] = ang;
Conta[playerid][saved_int] = GetPlayerInterior(playerid);
}
forward public LoadPlayerData(playerid);
public LoadPlayerData(playerid)
{
SetPlayerHealth(playerid, Conta[playerid][saved_health]);
if (Conta[playerid][saved_armour] > 0) SetPlayerArmour(playerid, Conta[playerid][saved_armour]);
GivePlayerMoney(playerid, Conta[playerid][saved_money]-GetPlayerMoney(playerid));
SetPlayerSkin(playerid, Conta[playerid][saved_skin]);
SetPlayerPos(playerid, Conta[playerid][saved_X], Conta[playerid][saved_Y], Conta[playerid][saved_Z]);
SetPlayerFacingAngle(playerid, Conta[playerid][saved_ang]);
SetPlayerInterior(playerid, Conta[playerid][saved_int]);
}