2 questions?? HELP ME
#1

First:- How to make a USAGE ERROR SCM??
Like if a cmd is /help and the player types /h he will get a SCM that [USAGE]/help??

Second:- Can someone explain me about string ? like [PLAYER 1] has killed [PLAYER 2] ?? HOw do i get usernames in the place of player 1 and 2 ??
Reply
#2

Use the OnPlayerCommandPerformed callback with zeex's zcmd.
pawn Код:
if(!success) return SCM(playerid,COLOR, "Please use /help for available commands.");
Reply
#3

? i want a usage error for all cmds an example?
Reply
#4

Can you explain more on #1?

An example for #2.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)
    {
        new WeapName[32], Name[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
        GetWeaponName(reason, WeapName, sizeof(WeapName));
        GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
        GetPlayerName(killerid, KillerName, MAX_PLAYER_NAME);
        format(string, sizeof(string),"%s (%d) has killed %s (%d) with a %s. ", Name, playerid, KillerName, killerid, WeapName);
        SendClientMessageToAll(-1, string);
    }
    return 1;
}
Reply
#5

ok understood #2 but -1 in SCM ??

#1 = if a player types /h instead of /help
the player should get a message "Please type /cmds for commands"
Reply
#6

Quote:
Originally Posted by rangerxxll
Посмотреть сообщение
Use the OnPlayerCommandPerformed callback with zeex's zcmd.
pawn Код:
if(!success) return SCM(playerid,COLOR, "Please use /help for available commands.");
This will probably solve #1

or:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) SendClientMessage(playerid, -1, "Unknown command. Type /cmds for commands.");
    return 1;
}
Reply
#7

ok thanks
Reply
#8

hey another doubt on #2 is that a order %s first and %d following that?
Reply
#9

They're placeholders. When you want to pass a string as argument, the placeholder must be %s. Read below for more placeholders and their meanings.

SpecifierMeaning
%iInteger (whole number)
%dInteger (whole number).
%sString
%fFloating-point number (Float: tag)
%cASCII character
%xHexadecimal number
%b Binary number
%%Literal '%'
Reply
#10

ohh ok so he used %s for Name and %d for playerid
Thanks +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)