about worldtime
#1

how do i make it like this?

|

this is my code

Код:
stock GetDayName()
{
	new DayName[128];
    switch(gday)
    {
		case 0: format(DayName, sizeof(DayName), "Sunday");
        case 1: format(DayName, sizeof(DayName), "Monday");
        case 2: format(DayName, sizeof(DayName), "Tuesday");
        case 3: format(DayName, sizeof(DayName), "Wednesday");
        case 4: format(DayName, sizeof(DayName), "Thursday");
        case 5: format(DayName, sizeof(DayName), "Friday");
        case 6: format(DayName, sizeof(DayName), "Saturday");
    }
    return DayName;
}
Reply
#2

Quote:
Originally Posted by PowerF
Посмотреть сообщение
how do i make it like this?

|

this is my code

Код:
stock GetDayName()
{
	new DayName[128];
    switch(gday)
    {
		case 0: format(DayName, sizeof(DayName), "Sunday");
        case 1: format(DayName, sizeof(DayName), "Monday");
        case 2: format(DayName, sizeof(DayName), "Tuesday");
        case 3: format(DayName, sizeof(DayName), "Wednesday");
        case 4: format(DayName, sizeof(DayName), "Thursday");
        case 5: format(DayName, sizeof(DayName), "Friday");
        case 6: format(DayName, sizeof(DayName), "Saturday");
    }
    return DayName;
}
Add your in gamemode or filterscript
PHP код:
stock SetServerWorldTime(text[]) { 
    new 
msg[128];
    
format(msgsizeof(msg), "worldtime %s"text);
    
SendRconCommand(msg);

And test:
PHP код:
formag(msgsizeof(msg), "%s, %02d:%02d"weekdayhoursminutes);
SetServerWorldTime(msg);
// print worldtime: Sunday, 10:30 
Reply
#3

Quote:
Originally Posted by Logofero
Посмотреть сообщение

And test:
PHP код:
formag(msgsizeof(msg), "%s, %02d:%02d"weekdayhoursminutes);
SetServerWorldTime(msg);
// print worldtime: Sunday, 10:30 
where do i add this?
Reply
#4

Quote:
Originally Posted by PowerF
Посмотреть сообщение
where do i add this?
At the top of your script.
PHP код:
#include <samp_a>
// <- This 
PS: It was just an example you have to add to it in accordance with your desire. If you do not know how to use an example, then you need to learn the basics of scripting.
Reply
#5

it's 'format' right?you typing it 'formag' :/

Код:
F:\cnr\gamemodes\CnR.pwn(59) : error 025: function heading differs from prototype
F:\cnr\gamemodes\CnR.pwn(59) : error 010: invalid function or declaration
F:\cnr\gamemodes\CnR.pwn(59) : error 021: symbol already defined: "formatex"
F:\cnr\gamemodes\CnR.pwn(59) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
this

Код:
format(msg, sizeof(msg), "%s, %02d:%02d", weekday, hours, minutes);
SetServerWorldTime(msg);
Reply
#6

Quote:
Originally Posted by PowerF
Посмотреть сообщение
it's 'format' right?you typing it 'formag' :/

Код:
F:\cnr\gamemodes\CnR.pwn(59) : error 025: function heading differs from prototype
F:\cnr\gamemodes\CnR.pwn(59) : error 010: invalid function or declaration
F:\cnr\gamemodes\CnR.pwn(59) : error 021: symbol already defined: "formatex"
F:\cnr\gamemodes\CnR.pwn(59) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
this

Код:
format(msg, sizeof(msg), "%s, %02d:%02d", weekday, hours, minutes);
SetServerWorldTime(msg);
It happens to everyone.
In any case, I helped you.
Reply
#7

Then?...
Reply
#8

OK. Here's an extended example.

Your gamemode.pwn or filterscript.pwn
PHP код:
/*
 * Show day of the week
 * © 2015 SAMP Community
 */
enum E_SRV_TIME {
    
WEEKDAY,
    
HOURS,
    
MINUTES,
    
TIMER
}
new 
server_time[E_SRV_TIME];
stock SetServerWorldTime(weekdayhoursminutes) { 
    new 
msg[128];
    
format(msgsizeof(msg), "worldtime %s, %02d:%02d"GetDayName(weekday), hoursminutes);
    
SetWorldTime(hours); // for update real time
    
SendRconCommand(msg);

stock GetDayName(gday) {
    new 
DayName[16];
    switch(
gday) {
    case 
0DayName "Sunday";
        case 
1DayName "Monday";
        case 
2DayName "Tuesday";
        case 
3DayName "Wednesday";
        case 
4DayName "Thursday";
        case 
5DayName "Friday";
        case 
6DayName "Saturday";
        default: 
DayName "Sunday";
    }
    return 
DayName;

public 
OnGameModeInit() {
    
server_time[TIMER] = SetTimer("OnTimeUpdate"1000true);
    return 
1;
}
public 
OnGameModeExit() {
    
KillTimer(server_time[TIMER]);
    return 
1;
}
forward OnTimeUpdate();
public 
OnTimeUpdate() {
    
server_time[MINUTES]++;
    if (
server_time[MINUTES] >= 60) {
          
server_time[MINUTES] = 0;
          
server_time[HOURS]++;
    }
    if (
server_time[HOURS] >= 24) {
         
server_time[HOURS] = 0;
         
server_time[WEEKDAY]++;
    }
    if (
server_time[WEEKDAY] >= 7) {
         
server_time[WEEKDAY] = 0;
    }
    
SetServerWorldTime(server_time[WEEKDAY], server_time[HOURS], server_time[MINUTES]); // update text worldtime: weekdat, hours:minutes
    
return 1;

Reply
#9

Here's what happened
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)