Problem with timers.
#1

Hello,
I made a paycheck system which included two timers,one for showing it and the second to hide that,but I really messes up when I put that in the server so can anyone help me do it with one timer?Please.
Here are the codes:
PHP код:
#include <a_samp>
#if defined FILTERSCRIPT
#include <sscanf2>
#include <YSI\y_commands>
public OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Blank Filterscript by your name here");
    print(
"--------------------------------------\n");
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
}
#else
new Text:Textdraw0;
new 
Text:Textdraw1;
forward paycheck(playerid);
forward paycheckshow(playerid);
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
#endif
public OnGameModeInit()
{
    
// Don't use these lines if it's a filterscript
    
SetGameModeText("Blank Script");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    
Textdraw0 TextDrawCreate(493.000000302.000000"PayCheck");
    
TextDrawBackgroundColor(Textdraw0255);
    
TextDrawFont(Textdraw03);
    
TextDrawLetterSize(Textdraw00.8299993.799999);
    
TextDrawColor(Textdraw016711935);
    
TextDrawSetOutline(Textdraw00);
    
TextDrawSetProportional(Textdraw01);
    
TextDrawSetShadow(Textdraw04);
    
Textdraw1 TextDrawCreate(575.000000337.000000"$500");
    
TextDrawBackgroundColor(Textdraw1255);
    
TextDrawFont(Textdraw11);
    
TextDrawLetterSize(Textdraw10.5000003.299998);
    
TextDrawColor(Textdraw116711935);
    
TextDrawSetOutline(Textdraw10);
    
TextDrawSetProportional(Textdraw11);
    
TextDrawSetShadow(Textdraw14);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
       
SetTimerEx("paycheck",3600000,true,"i",playerid);
       
SetTimerEx("paycheckshow",3555599,true,"i",playerid);
    return 
1;
}
YCMD:setlevel(playeridparams[])
{
    if(
gPlayerLoggedIn[playerid] == 0) return 1;
    if(
IsPlayerAdmin(playerid) {
        new 
skinplayer;
        if(
sscanf(params"ud"playerskin)) return SendClientMessage(playeridCOLOR_GREY"[USAGE]: /setlevel [Part of Name/ID] [level]");
        if(!
IsPlayerConnected(player)) return SendClientMessage(playeridCOLOR_GREY"Player is not connected.");
        
        
SetPlayerScore(playerscore);
        new 
string[126];
        
format(stringsizeof(string), "AdmWarning: %s set %s's level to %d."PlayerName(playerid), PlayerName(player), level);
        
AMessage(COLOR_LIGHTREDstring);
        return 
1;
    }
    return 
1;
}
public 
paycheckshow(playerid)
{
    
TextDrawHideForPlayer(playerid,Text:Textdraw0);
    
TextDrawHideForPlayer(playerid,Text:Textdraw1);
}
public 
paycheck(playerid)
{
    
TextDrawShowForPlayer(playerid,Text:Textdraw0);
    
TextDrawShowForPlayer(playerid,Text:Textdraw1);
    
GivePlayerMoney(playerid,500);
    for(new 
i=0!=  MAX_PLAYERSi++)
    {
        new 
score;
        
score GetPlayerScore(i);
        
SetPlayerScore(iscore+1);
    }

Reply
#2

bump..Please help me.
Reply
#3

Sorry for the second bump but please please I need this,someone.
Reply
#4

I see you are using YSI, I recommend you using y_timers, and player tasks.

y_timers on SA-MP forums
Reply
#5

Can you give me a example with y timers on this?
Reply
#6

Quote:
Originally Posted by TaLhA XIV
Посмотреть сообщение
Can you give me a example with y timers on this?
Код:
ptask showpaycheck[3600000](playerid)
{
     // Your code to show the paycheck
}
ptask hidepaycheck[3610000](playerid)
{
    // Your code to hide the paycheck
}
That will show the paycheck to every player, every hour (3 600 000 milliseconds = 3600 seconds = 60 minutes = 1 hour), and hide it 10 seconds after.
Reply
#7

Okay thanks and one last question.How can I hide the textdraw for like 59:55 time?I want to thexdraw to appear for only 5 seconds?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)