Why this dont work?
#1

heey all,
I made a textdraw clock and i want that if the hour is passed that everybody get the message that the hour is passed but it dont work. I tried everything but the message dont show.
Код:
public IncreaseTime(playerid)
{
    new h, m;
    new string[20];
	//SetToNull(playerid);
	GetPlayerTimeEx(playerid, h, m);
    TextDrawShowForPlayer(playerid, time);
    m++;
    if(m == 60)
    {
        h++;
        m = 0;
    }
    if(h == 24)
    {

        h = 0;
    }
    SetPlayerTimeEx(playerid, h, m);
	if(m >= 0&&m < 9)
    {
	format(string, sizeof(string), "%d:0%d", h, m);
    TextDrawSetString(time,string);
    return 1;
    }
    if(m == 9)
    {
	format(string, sizeof(string), "%d:0%d", h, m);
    TextDrawSetString(time,string);
    return 1;
    }
    if(m >= 10&&m < 60)
    {
    format(string, sizeof(string), "%d:%d", h, m);
    TextDrawSetString(time,string);
	return 1;
	}
	if(h== 1)
	{
	SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 1:00");
	return 1;
	}
	if(h== 0)
	{
	SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 0:00");
	return 1;
	}

	SetWorldTime(h);
        format(string, sizeof(string), "[GAME TIME] %d:00", h);
	SendClientMessageToAll(COLOR_WHITE, string);
	return 1;
}
Pls help me out:S
Reply
#2

its because you create
pawn Код:
new h, m;
in the function so they will allways be 0 so it will never show make them global and it should work fine
Reply
#3

How can i fix this?
Reply
#4

found it try this
pawn Код:
public IncreaseTime(playerid)
{
    new h, m;
    new string[20];
    GetPlayerTimeEx(playerid, h, m);
    TextDrawShowForPlayer(playerid, time);
    m++;
    if(m == 60)
    {
        h++;
        m = 0;
    }
    if(h == 24)
    {
        h = 0;
    }
    SetPlayerTimeEx(playerid, h, m);
    if(m >= 0&&m < 9)
    {
        format(string, sizeof(string), "%d:0%d", h, m);
        TextDrawSetString(time,string);
    }
    else if(m == 9)
    {
        format(string, sizeof(string), "%d:0%d", h, m);
        TextDrawSetString(time,string);
    }
    else if(m >= 10&&m < 60)
    {
        format(string, sizeof(string), "%d:%d", h, m);
        TextDrawSetString(time,string);
    }
    if(h== 1)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 1:00");
    }
    else if(h== 0)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 0:00");
    }
    else {
        format(string, sizeof(string), "[GAME TIME] %d:00", h);
        SendClientMessageToAll(COLOR_WHITE, string);
        SetWorldTime(h);
    }
    return h;
}
and you might want to send the message just to the player or will spam your server each hour
Reply
#5

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
found it try this
pawn Код:
public IncreaseTime(playerid)
{
    new h, m;
    new string[20];
    GetPlayerTimeEx(playerid, h, m);
    TextDrawShowForPlayer(playerid, time);
    m++;
    if(m == 60)
    {
        h++;
        m = 0;
    }
    if(h == 24)
    {
        h = 0;
    }
    SetPlayerTimeEx(playerid, h, m);
    if(m >= 0&&m < 9)
    {
        format(string, sizeof(string), "%d:0%d", h, m);
        TextDrawSetString(time,string);
    }
    else if(m == 9)
    {
        format(string, sizeof(string), "%d:0%d", h, m);
        TextDrawSetString(time,string);
    }
    else if(m >= 10&&m < 60)
    {
        format(string, sizeof(string), "%d:%d", h, m);
        TextDrawSetString(time,string);
    }
    if(h== 1)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 1:00");
    }
    else if(h== 0)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 0:00");
    }
    else {
        format(string, sizeof(string), "[GAME TIME] %d:00", h);
        SendClientMessageToAll(COLOR_WHITE, string);
        SetWorldTime(h);
    }
    return h;
}
and you might want to send the message just to the player or will spam your server each hour
Thanks dude. But now its spamming lol
Reply
#6

welcome see how i changed it?
and you can go
pawn Код:
format(string, sizeof(string), "%d:%2d", h, m);
        TextDrawSetString(time,string);
for a 2sf number so it will print the 0 before 1-9 automagicly fyi
Reply
#7

now is fixed?
i used this but haved errors?
why
Reply
#8

Can i change this
Код:
if(h== 1)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 1:00");
    }
    else if(h== 0)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 0:00");
    }
    else {
        format(string, sizeof(string), "[GAME TIME] %d:00", h);
        SendClientMessageToAll(COLOR_WHITE, string);
        SetWorldTime(h);
    }
to this
Код:
if(h== 1 && m==0)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 1:00");
    }
    else if(h== 0&& m==0)
    {
        SendClientMessageToAll(COLOR_WHITE,"[GAME TIME] 0:00");
    }
    else {
        format(string, sizeof(string), "[GAME TIME] %d:00", h);
        SendClientMessageToAll(COLOR_WHITE, string);
        SetWorldTime(h);
    }
or something like that?
Reply
#9

How can i stop the spamming?
Reply
#10

how about like this
pawn Код:
public IncreaseTime(playerid)
{
    new h, m;
    new string[20];
    GetPlayerTimeEx(playerid, h, m);
    TextDrawShowForPlayer(playerid, time);
    m++;
    if(m == 60)
    {
        h++;
        m = 0;
    }
    if(h == 24)
    {
        h = 0;
    }
    SetPlayerTimeEx(playerid, h, m);
    if(m >= 0&&m < 60)
    {
        format(string, sizeof(string), "%d:%2d", h, m);
        TextDrawSetString(time,string);
    }
    if(m == 0){
        format(string, sizeof(string), "[GAME TIME] %d:00", h);
        SendClientMessage(playerid,COLOR_WHITE, string);
        SetWorldTime(h);
    }
    return h;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)