SA-MP Forums Archive
Help with timer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with timer (/showthread.php?tid=85966)



Help with timer - coole210 - 11.07.2009

Okay i have house system but i don't know how to make a GameTextForPlayer function for it :S example: format(string,sizeof(string),"~w~ Owner : %s",OWNER); GameTextForPlayer(blababla);

So the problem is every house is house ID 0! I bought house ID 0 and now everytime i go to every house i own it :S but i really don't!

Here's what i tried,

pawn Код:
forward GameTextTimer(playerid);
public GameTextTimer(playerid)
{
    new tmp[128];
    new cmdtext[128];
    new idx;
    tmp = strtok(cmdtext, idx);
    new id = strval(tmp);
    new string[256];
    for(new i = 0; i < MAX_PICKUPS; i++)
    {
        if(PlayerToPoint(3,playerid,Houses[id][EnterX],Houses[id][EnterY],Houses[id][EnterZ]))
        {
        format(string,sizeof(string),"~w~%s~n~~g~Owner: %s~n~~w~Price: %d~n~Rent: %d",Houses[id][Description],Houses[id][Owner],Houses[id][HousePrice],Houses[id][RentCost]);
        GameTextForPlayer(playerid, string, 500, 3);
        }
    }
    return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("GameTextTimer", 1, true, "i", playerid);
    return 1;
}



Re: Help with timer - Finn - 11.07.2009

What's this shit?
pawn Код:
new tmp[128];
new cmdtext[128];
new idx;
tmp = strtok(cmdtext, idx);
new id = strval(tmp);
new string[256];
Try without those lines:
pawn Код:
forward GameTextTimer(playerid);
public GameTextTimer(playerid)
{
  new string[128];
  for(new i = 0; i < MAX_PICKUPS; i++)
  {
    if(PlayerToPoint(3,playerid,Houses[i][EnterX],Houses[i][EnterY],Houses[i][EnterZ]))
    {
      format(string,sizeof(string),"~w~%s~n~~g~Owner: %s~n~~w~Price: %d~n~Rent: %d",Houses[i][Description],Houses[i][Owner],Houses[i][HousePrice],Houses[i][RentCost]);
      GameTextForPlayer(playerid, string, 500, 3);
    }
  }
  return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
  SetTimerEx("GameTextTimer", 1000, true, "i", playerid);
  return 1;
}
Your timer was set to 1 milisecond, so I set it to 1000, which means the timer will be called each second, not each milisecond.