搜索
查看: 2189|回复: 6

[求助]get_user_time的返回值是16进制的吗?

[复制链接]
发表于 2007-1-15 21:29:50 | 显示全部楼层 |阅读模式 来自 澳大利亚
看过slots_reservation.sma,里面有一段:

new who = 0, time, shortest = 0x7fffffff
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; i++){
  if ( !is_user_connected(i) && !is_user_connecting(i) )
   continue // 跳过没有分配给玩家的空id
  if (get_user_flags(i)&ADMIN_RESERVATION)
   continue // 跳过有通道使用权的玩家
  time = get_user_time(i,1) // get user playing time,the connection time is minused.
  if ( shortest > time ) {
   shortest = time

--->shortest = 0x7fffffff 这个的单位是秒吗? 定义成0xffffffffffffff等等足够大就行吧?

还有个小问题:
new userip[17]
get_user_ip(id,userip,16,1)
不知道
new userip[16]和get_user_ip(id,userip,15,1)行不行?
自己理解get_user_ip在 [ without_port=1 ]时应该类似"192.168.0.1\0"这样的自串
发表于 2007-1-16 03:01:12 | 显示全部楼层 来自 中国–广东–深圳

回复: [求助]get_user_time的返回值是16进制的吗?

[php]
/* Returns player playing time in seconds. *
If flag is set then result is without connection time. */
native get_user_time(index, flag = 0);
[/php]
get_user_time 返回秒(整数)

还有个小问题:
new userip[17]
get_user_ip(id,userip,16,1)
不知道
new userip[16]和get_user_ip(id,userip,15,1)行不行?
不行,因为最长的ip为 255.255.255.255 (共16位字符)
如果用userip[16] 只能保存15位串,那就少了一位了

自己理解get_user_ip在 [ without_port=1 ]时应该类似"192.168.0.1\0"这样的自串
正确,看 amxmodx.inc 里的注解
[php]
/* Returns ip. */
native get_user_ip(index,ip[],len, without_port = 0);
// 当 without_port = 1时,表示不返回端口号
[/php]
回复

使用道具 举报

 楼主| 发表于 2007-1-16 09:21:52 | 显示全部楼层 来自 叙利亚

回复: [求助]get_user_time的返回值是16进制的吗?

我觉得new userip[16]的话应该可以保存16位,"userip[0]-userip[15]对应"255.255.255.255\0'',也许small的数组和c的不同?

感谢jop的回复,懂了不少,凌晨3点...辛苦~~
回复

使用道具 举报

发表于 2007-1-16 10:27:20 | 显示全部楼层 来自 中国–陕西–西安

回复: [求助]get_user_time的返回值是16进制的吗?

Post by mythkina
我觉得new userip[16]的话应该可以保存16位,"userip[0]-userip[15]对应"255.255.255.255\0'',也许small的数组和c的不同?

感谢jop的回复,懂了不少,凌晨3点...辛苦~~
是的,用new userip[16]就可以了。
回复

使用道具 举报

 楼主| 发表于 2007-1-16 11:07:50 | 显示全部楼层 来自 中国–辽宁–沈阳

回复: [求助]get_user_time的返回值是16进制的吗?

收到, 谢谢Rulzy~~
回复

使用道具 举报

发表于 2007-1-16 12:42:09 | 显示全部楼层 来自 中国–广东–潮州

回复: [求助]get_user_time的返回值是16进制的吗?

其他的语言没接触过,不过就AMXX的small、结合游戏本身来说,我觉得尽可能考虑所有变数是良好习惯。
这也是2楼弟兄 ( 花1个月从零开始学习 + 金山词霸 ) > ( N年计算机语言基础 + 英语6级 ) 的原因。
回复

使用道具 举报

发表于 2007-1-16 16:22:33 | 显示全部楼层 来自 中国–广东–深圳–罗湖区

回复: [求助]get_user_time的返回值是16进制的吗?

哦,我犯了低级错误,忘了ip[0]

Rulzy 正解
ip[16]可以用
回复

使用道具 举报

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

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