28.04.2018, 16:41
(
Последний раз редактировалось 1sbedx; 28.04.2018 в 18:05.
)
PHP код:
#include <a_samp>
#define MAX_LEVEL (4)
new ply_Level[MAX_PLAYERS];
new ply_Experience[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
SetPlayerLevel(playerid, 1);
SetPlayerExperience(playerid, 0);
return 1;
}
GetPlayerLevel(playerid)
return ply_Level[playerid];
GetPlayerExperience(playerid)
return ply_Experience[playerid];
SetPlayerLevel(playerid, level)
{
if (level > MAX_LEVEL)
return 1;
return ply_Level[playerid] = level;
}
GivePlayerLevel(playerid, level)
{
if (level > MAX_LEVEL)
return 1;
return ply_Level[playerid] += level;
}
SetPlayerExperience(playerid, experience)
{
if (experience > GetLevelExperience(GetPlayerLevel(playerid)))
return 1;
return ply_Experience[playerid] = experience;
}
GivePlayerExperience(playerid, experience)
{
if (experience > GetLevelExperience(GetPlayerLevel(playerid)))
return 1;
return ply_Experience[playerid] += experience;
}
GetLevelExperience(level)
{
switch (level)
{
case 1: return 4;
case 2: return 15;
case 3: return 30;
case 4: return 50;
}
return 0; // Invalid level
}
public OnPlayerUpdate(playerid) // Nгo use aqui, й apenas um exemplo!!
{
GivePlayerExperience(playerid, 1);
if (GetPlayerExperience(playerid) >= GetLevelExperience(GetPlayerLevel(playerid)))
{
GivePlayerLevel(playerid, 1);
SetPlayerExperience(playerid, 0);
}
printf("playerid %d - Level %d (%d/%d)", playerid, GetPlayerLevel(playerid), GetPlayerExperience(playerid), GetLevelExperience(GetPlayerLevel(playerid)));
return 1;
}