搜索
查看: 3337|回复: 4

问个比较寒的问题——今天星期几?

[复制链接]
发表于 2007-12-29 19:08:07 | 显示全部楼层 |阅读模式 来自 中国–广东–中山
在游戏中可以通过插件获取日期和时刻,但怎样才能知道今天星期几?
发表于 2007-12-29 19:16:42 | 显示全部楼层 来自 中国–福建–漳州

回复: 问个比较寒的问题——今天星期几?

new WEEK[7][] = {"日","一","二","三","四","五","六"}
new sWeek[2]
get_time("%w", sWeek, 1)
WEEK[str_to_num(sWeek)]
回复

使用道具 举报

 楼主| 发表于 2007-12-29 23:50:06 | 显示全部楼层 来自 中国–广东–中山

回复: 问个比较寒的问题——今天星期几?

Post by Rulzy
new WEEK[7][] = {"日","一","二","三","四","五","六"}
new sWeek[2]
get_time("%w", sWeek, 1)
WEEK[str_to_num(sWeek)]

先感谢一下。
说实话, 看不懂。get_time不是返回当前时间的吗?
:cry:
回复

使用道具 举报

发表于 2007-12-30 07:53:40 | 显示全部楼层 来自 中国–浙江–嘉兴–海宁市

回复: 问个比较寒的问题——今天星期几?

get_time("%w", sWeek, 1)
"%w",

注意这个参数
回复

使用道具 举报

发表于 2007-12-30 15:29:24 | 显示全部楼层 来自 中国–甘肃–兰州

回复: 问个比较寒的问题——今天星期几?

[PHP]/*
*  AMX X Mod script.
*
* (c) Copyright 2004, olol
*
* This file is provided as is (no warranties).
*/
#include <amxmod>
/*
* TimeProjector displays the time and the next map on the top right corner of the client
* display as a hudmessage.
*
* History:
*
* v0.1: -  
*/

public show_timer(id){
    new MONTHS[12][] = {"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"}
    new WEEK[7][] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}
    new DAY[31][] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"}
    new nextmap[32]
    new cumap[32]
    new timel = get_timeleft()
    new ns_Hour[3], ns_Minutes[3],ns_Month[3],ns_Day[3],ns_Year[5],ns_second[3],ns_week[5]
    get_cvar_string("amx_nextmap",nextmap,31)
    get_mapname(cumap,31)
    get_time("%H", ns_Hour, 2)
    get_time("%M", ns_Minutes, 2)
    get_time("%m", ns_Month, 2)
    get_time("%d", ns_Day, 2)
    get_time("%Y", ns_Year, 4)
    get_time("%S", ns_second, 2)
    get_time("%w", ns_week, 4)   
    set_hudmessage(0,255,0,0.13,0.07,0, 1.0, 1.0, 0.1, 0.2, 12)
    if((str_to_num(ns_week)) ==0){
    show_hudmessage(id,"%s-%s-%s %s Day^n PresTime:  %s:%s:%s^n PresMap:  %s^n NextMap:  %s^n SurpTime:  %d:%02d",ns_Year,MONTHS[str_to_num(ns_Month) -1],DAY[str_to_num(ns_Day) -1],WEEK[str_to_num(ns_week) +6],ns_Hour,ns_Minutes,ns_second,cumap,nextmap,timel / 60, timel % 60)
    }else{
    show_hudmessage(id,"%s-%s-%s %s Day^n PresTime:  %s:%s:%s^n PresMap:  %s^n NextMap:  %s^n SurpTime:  %d:%02d",ns_Year,MONTHS[str_to_num(ns_Month) -1],DAY[str_to_num(ns_Day) -1],WEEK[str_to_num(ns_week) -1],ns_Hour,ns_Minutes,ns_second,cumap,nextmap,timel / 60, timel % 60)
    }
    return PLUGIN_CONTINUE
}
public plugin_init()
{
    register_plugin("TimeProjector","0.1","olol")
    //register_clcmd("say nowtime","show_timer")
    set_task(1.0, "show_timer",0,"",0,"b")
    return PLUGIN_CONTINUE
} [/PHP]
可以参考一下TimeProjector.amxx这个插件的源代码.
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表