[Ajuda]Sistema Level
#1

Alguns jogadores evoluem mais rapido que outros,mesmo estando connectados o mesmo tempo.
Houve jogadores que passaram do Level 0 para o 2...e depois para o 4.

A unica coisa que mudei foi o OnPlayerUpdate para fazer o score aparecer no TAB

Код:
#include <a_samp>
#include <dini>


#define COR_AQUI      0xFFFFFFAA


new Level[MAX_PLAYERS];
new Respeito[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
	if(dini_Isset("levels.dkn",PlayerName(playerid))) Level[playerid] = (playerid,dini_Int("levels.dkn",PlayerName(playerid)));
	SetTimerEx("Timer",60000,true,"i",playerid);
	return 1;
}

forward Timer(playerid);
public Timer(playerid)
{
	Respeito[playerid]++;
	SendClientMessage(playerid,COR_AQUI,"Gratz,your respect has grown a bit more!!");
	if(Respeito[playerid] == 5)
	{
		Level[playerid]++;
		SendClientMessage(playerid,COR_AQUI,"Gratz,you leveled up!!");
		Level[playerid]++;
	}
	return 1;
}

public OnGameModeInit()
{
	if(!fexist("levels.dkn")) dini_Create("levels.dkn");
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	dini_IntSet("levels.dkn",PlayerName(playerid),Level[playerid]);
	return 1;
}

public OnPlayerUpdate(playerid)
{
    dini_IntSet("levels.dkn",PlayerName(playerid),Level[playerid]);
    if(dini_Isset("levels.dkn",PlayerName(playerid))) SetPlayerScore(playerid,dini_Int("levels.dkn",PlayerName(playerid)));
    return 1;
}

stock PlayerName(playerid)
{
	new PlayerNameLevel[MAX_PLAYERS];
	GetPlayerName(playerid, PlayerNameLevel, MAX_PLAYERS);
	return PlayerNameLevel;
}
Alguem me pode ajudar?
Reply
#2

pawn Код:
Level[playerid]++;
SendClientMessage(playerid,COR_AQUI,"Gratz,you leveled up!!");
Level[playerid]++;
Tenta trocar por apenas :
pawn Код:
Level[playerid]++;
SendClientMessage(playerid,COR_AQUI,"Gratz,you leveled up!!");
Reply
#3

Quote:
Originally Posted by DonBruno
Посмотреть сообщение
public Timer(playerid)
{
Respeito[playerid]++;
SendClientMessage(playerid,COR_AQUI,"Gratz,your respect has grown a bit more!!");
if(Respeito[playerid] == 5)
{
Level[playerid]++;
SendClientMessage(playerid,COR_AQUI,"Gratz,you leveled up!!");
Level[playerid]++;
}
return 1;
}
Vocк estб dando o nivel duas vezes, apague a parte que eu coloquei em negrito
Reply
#4

pawn Код:
forward Timer(playerid);
public Timer(playerid)
{
    Respeito[playerid]++;
    SendClientMessage(playerid,COR_AQUI,"Gratz,your respect has grown a bit more!!");
    if(Respeito[playerid] == 5)
    {
        SendClientMessage(playerid,COR_AQUI,"Gratz,you leveled up!!");
        Level[playerid]++;
    }
    return 1;
}
Reply
#5

pawn Код:
#include <a_samp>
#include <dini>


#define COR_AQUI      0xFFFFFFAA


new Level[MAX_PLAYERS];
new Respeito[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    if(dini_Isset("levels.dkn",PlayerName(playerid))) Level[playerid] = (playerid,dini_Int("levels.dkn",PlayerName(playerid)));
    SetTimerEx("Timer",60000,true,"d",playerid);
    return 1;
}

forward Timer(playerid);
public Timer(playerid)
{
    Respeito[playerid]++;
    SendClientMessage(playerid,COR_AQUI,"Gratz,your respect has grown a bit more!!");
    if(Respeito[playerid] == 5)
    {
        SendClientMessage(playerid,COR_AQUI,"Gratz,you leveled up!!");
    }
    return 1;
}

public OnGameModeInit()
{
    if(!fexist("levels.dkn")) dini_Create("levels.dkn");
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    dini_IntSet("levels.dkn",PlayerName(playerid),Level[playerid]);
    return 1;
}

public OnPlayerConnect(playerid)
{
    dini_IntSet("levels.dkn",PlayerName(playerid),Level[playerid]);
    if(dini_Isset("levels.dkn",PlayerName(playerid))) SetPlayerScore(playerid,dini_Int("levels.dkn",PlayerName(playerid)));
    return 1;
}

stock PlayerName(playerid)
{
    new PlayerNameLevel[MAX_PLAYERS];
    GetPlayerName(playerid, PlayerNameLevel, MAX_PLAYERS);
    return PlayerNameLevel;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)