简体   繁体   English

PAWN 中的一个简单命令

[英]A simple command in PAWN

San Andreas Multiplayer (GTA) uses PAWN as its programming language. San Andreas Multiplayer (GTA) 使用 PAWN 作为其编程语言。 I'm an owner of a server on SA-MP and I'm not that pro so I'd like to get some help if possible.我是 SA-MP 上服务器的所有者,但我不是那么专业,所以如果可能的话,我想获得一些帮助。 Basically, I have a command that checks player's statistics when he/she is online, but I'd like to have a command to check them when they're offline.基本上,我有一个命令可以在玩家在线时检查他/她的统计信息,但是我想要一个命令来在他们离线时检查他们。 That's the code of the commmand which checks player's statistics when he's online.这是命令的代码,用于检查玩家在线时的统计信息。

CMD:check(playerid, var[])
{
    new user;
    if(!Logged(playerid)) return NoLogin(playerid);
    if(Player[playerid][pAdmin] >= 2 || Player[playerid][pStaffObserver])
    {
        if(sscanf(var,"us[32]", user, var))
        {
            SendClientMessage(playerid, COLOR_WHITE, "{00BFFF}Usage:{FFFFFF} /check [playerid] [checks]");
            SendClientMessage(playerid, COLOR_GRAD2, "** [CHECKS]: stats");
            return 1;
        }
        if(!strcmp(var, "stats", true))
        {
            if(!Logged(user)) return NoLoginB(playerid);
            ShowStats(playerid, user);
        }
    }
    else
    {
        NoAuth(playerid);
    }
    return 1;
}

I use ZCMD command processor and Dini saving system.我使用 ZCMD 命令处理器和 Dini 保存系统。 So I'd like to make CMD:ocheck that would display the stock ShowStats and it'll work like /ocheck [Firstname_Lastname].所以我想让 CMD:ocheck 显示股票 ShowStats,它会像 /ocheck [Firstname_Lastname] 一样工作。

Any help?有什么帮助吗? Please help if possible.如果可能,请帮忙。

Thanks谢谢

~Kevin ~凯文

For the command that you require, you'll have to load data from the player's userfile.对于您需要的命令,您必须从播放器的用户文件中加载数据。

You'll obviously begin with你显然会开始

if(!Logged(playerid)) return NoLogin(playerid);
if(Player[playerid][pAdmin] >= 2 || Player[playerid][pStaffObserver]) 
{

To check if the player using this is authorized to use this command.检查使用此命令的玩家是否有权使用此命令。 Following this,按照此,

if(str, "s[32]", name))

You cannot use 'u' as a formatter here, simply because you're checking an offline player's statistics.您不能在这里使用 'u' 作为格式化程序,因为您正在检查离线玩家的统计数据。 After this, you need to check if the user is actually registered If he isn't, you return that error the user of this command If he is, then check if he is online already.在此之后,您需要检查用户是否实际注册 如果他没有注册,则返回此命令的用户的错误 如果他是,则检查他是否已经在线。 If he is online, return error to admin to use this command instead of 'ocheck' If he's offline, then you can safely proceed to load his statistics (you can use the code used for loading data when a player logs in, except this time it should only be printed如果他在线,返回错误给管理员使用这个命令而不是'ocheck' 如果他离线,那么你可以安全地继续加载他的统计数据(你可以使用玩家登录时用于加载数据的代码,除了这次它应该只打印

for eg,例如,

format(str, sizeof(str), 
"Score: %s, Money: %d", 
dini_Int(file, "score"), dini_Int(file, "score") );

是的,基本上,您必须从文件中获取所有信息,因此 ShowStats 将不起作用,因为我想它从枚举中获取所有信息,因此您必须编写一个全新的函数来获取所有离线信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM