SetTimerEx only for one player?!
#1

Hello,
im using SetTimerEx to count 1 second and set a timer for my leveling system.
But the timer works only for one player. If i connect on the server, it work for me.
But if anyone join on the server and he looks to his own timer, it not work.
I will for ever player a counter to safe theri skill data

WHat is false?

Код:
public OnGameModeInit()
{
new playerid[MAX_PLAYERS];
SetTimerEx("TimeOnServer", 1000, true, "i", playerid);
....
Код:
forward TimeOnServer(playerid);
public TimeOnServer(playerid)
{
    SpielerInfo[playerid][pPlayerTimeSec] ++;
    if(SpielerInfo[playerid][pPlayerTimeSec]>=60)
    {
        SpielerInfo[playerid][pPlayerTimeSec]=0;
	SpielerInfo[playerid][pPlayerTimeMin]++;
    }
    if(SpielerInfo[playerid][pPlayerTimeMin]>=60)
    {
        SpielerInfo[playerid][pPlayerTimeMin]=0;
        SpielerInfo[playerid][pPlayerTimeHour]++;
        SpielerInfo[playerid][pSkill]++;
        PlayerPlaySound(playerid,1149,0,0,0);
        SendClientMessage(playerid, red, "[SKILL] {FFFFFF}Du hast +1 Skillpunkt erhalten");
    }
    if(SpielerInfo[playerid][pPlayerTimeHour]>=24)
    {
        SpielerInfo[playerid][pPlayerTimeHour]=0;
        SpielerInfo[playerid][pPlayerTimeDay]++;
    }
    if(SpielerInfo[playerid][pSkill]>=10)
    {
        SpielerInfo[playerid][pSkill]=0;
	SpielerInfo[playerid][pLevel]++;
        SendClientMessage(playerid, red, "[SKILL] {FFFFFF}Du hast +1 Level erhalten");
    }
}
Reply
#2

Put the SetTimerEx in OnPlayerConnect
Reply
#3

now with OnPlayerConnect.
if i join first it works all perfektly, if the second player join the tuper update to 2 sekonds (2,4,6...) per second
now if one more connect the timer junps to (3,6,9...) per second.
if nobody on the server and i join again, the last updatet state count agan ( but with + 1) like last was 3,6,9

now its 4,8,12 per sekond...

i need only +1 per second ^^
Reply
#4

any other idea? ^^
Reply
#5

you pass playerid as a parameter
Код:
forwrad timer(i); // timer

public timer(i)
{
    SendClinetMessage(i ,COLOR ,"BLA BLA");
}

// how to use it
SetTimerEx("timer", 1000, false, "i", playerid);
Reply
#6

i dont understand how to convert my code now, and why? "i"?
Reply
#7

Simple: Use KillTimer when the player disconnects, also, reset the variables at his connection, and load at login.

https://sampwiki.blast.hk/wiki/SetTimerEx
https://sampwiki.blast.hk/wiki/KillTimer
Reply
#8

i failed and posted my msg in the wrong topic

p.s. how do I delete a post?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)