GivePlayerWeapon with dcmd
#6

Quote:
Originally Posted by luckie12
Посмотреть сообщение
I know what Zcmd is , but im wondering, where is Sscanf used for?
THe download link for Sscanf is not working at the thread ?
Sscanf is used for scanning and comparing strings aswell as defining paramterers and attaching each parameter to a variable. For example:

I have the command "/kick <playerid/partofname> <reason>"

pawn Код:
CMD:kick(playerid, params[]) {
     new id, reason;
     if(sscanf(params, "us[100]", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /kick <playerid/partofname> <reason>");
}
Where "us[100]" can be split up to "u" and "s[100]". The u defines a playerid or part of the players name. the s[100] tells you that we're looking for a string up to 100 characters in the parameters.

If the parameters in the command is not entered as shown above, we will then return the syntax-message.

You can with the rest of the command use the parameters we've entered.

pawn Код:
CMD:kick(playerid, params[]) {
    new id, reason, name[MAX_PLAYER_NAME];
    if(sscanf(params, "us[100]",id, reason)) return SendClientMessage(playerid, -1, "USAGE: /kick <playerid/partofname> <reason>");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You're not an admin.");
    Kick(id);
    GetPlayerName(id, name, sizeof(name));
    format(string, sizeof(string), "%s has been kicked of the server. Reason: %s", name, reason);
    SendClientMessageToAll(-1, string);
    return 1;
}
Github downloads are here: https://github.com/maddinat0r/sscanf/releases
Reply


Messages In This Thread
GivePlayerWeapon with dcmd - by luckie12 - 28.03.2016, 13:57
Re: GivePlayerWeapon with dcmd - by Luis- - 28.03.2016, 14:03
Re: GivePlayerWeapon with dcmd - by luckie12 - 28.03.2016, 14:04
Re: GivePlayerWeapon with dcmd - by introzen - 28.03.2016, 14:07
Re: GivePlayerWeapon with dcmd - by luckie12 - 28.03.2016, 14:10
Re: GivePlayerWeapon with dcmd - by introzen - 28.03.2016, 14:29
Re: GivePlayerWeapon with dcmd - by luckie12 - 28.03.2016, 14:34
Re: GivePlayerWeapon with dcmd - by luckie12 - 28.03.2016, 14:40
Re: GivePlayerWeapon with dcmd - by introzen - 28.03.2016, 14:41
Re: GivePlayerWeapon with dcmd - by luckie12 - 28.03.2016, 14:55

Forum Jump:


Users browsing this thread: 2 Guest(s)