Clock system
#1

Hi, I'm using this script for my clock system:
pawn Код:
#include <a_samp>
#define WHITE 0xFFFFFFAA

new Text:Servt;
new Tsec;
new THrs;

public OnFilterScriptInit()
{

    SetWorldTime(Servt);

    Servt = TextDrawCreate(545, 31, "00:00");
    TextDrawColor(Servt, WHITE);
    Tsec= 0;
    THrs= 0;
    SetTimer("TimeU", 60000,true);


    return 1;
}

public OnFilterScriptExit()
{
    TextDrawDestroy(Servt);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Servt);
    return 1;
}

forward TimeU(playerid);

public TimeU(playerid)
{
    new string[7];                              // it makes a variable for a string with size 128
    Tsec+=1;                                      //this adds 1 to the existing time variable
    if(Tsec==60) {                                //this resets the mins to 00 one it reaches 60
        Tsec=00;
        THrs+=1;                                  //this adds 1 to the hours every 60 seconds
    }
    if(THrs==24) {                                //This Checks if time is 24:00
        Tsec=00;                                  //This Sets resets Mins
        THrs=0;                                   //this Resets Hours
    }
    if(Tsec<10) {                                 // This Adds a 0 Before The Mins Display For it To look like an actual clock
                                                  //formats string
        format(string,sizeof(string),"%d:%d0",THrs,Tsec);

    }
    if(Tsec>10) {                                 // This Removes a 0 Before The Mins Display after it has reached 10
                                                  //formats string
        format(string,sizeof(string),"%d:%d",THrs,Tsec);

    }
    if(THrs<10) {
                                                  //formats string
        format(string,sizeof(string),"0%d:%d",THrs,Tsec);

    }
    for(new i; i<MAX_PLAYERS; i++) {              //loops through all players
        if(IsPlayerConnected(i)) {                //checks if the player is connected
            SetPlayerTime(i,THrs,Tsec);           //sets All players time
        }
    }
    TextDrawSetString(Servt,string);              //updates the textdraw

}
And I get this warning after compiling

Код:
C:\Users\Cretu\Downloads\GTA SA\Server Fri CnR\filterscripts\clock.pwn(11) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
The problem line is
pawn Код:
SetWorldTime(Servt);
Please help me solve this..
Reply
#2

You can't set the world time with a textdraw, which is what you are doing.
Reply
#3

Then how can I make players able to see it without a textdraw?
Is there a script to enable the default Singleplayer clock and make it able to set the whole server time?
Reply
#4

You can still use the textdraw, you just can't set the world time as a textdraw. You need to set the world time as a number, because the time is always a number, the time is never a textdraw, it's like real life, the time is always a number, like 12, or 7..

https://sampwiki.blast.hk/wiki/SetWorldTime

SetWorldTime sets the hour, so:
pawn Код:
SetWorldTime(12);
Reply
#5

But what about the singleplayer default clock? Can I enable it with a script?
Reply
#6

^ https://sampwiki.blast.hk/wiki/TogglePlayerClock
Reply
#7

And can I set the whole server time to go by that clock?
Reply
#8

EDIT: It's fine, works.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)