SA-MP Forums Archive
2 questions?? HELP ME - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: 2 questions?? HELP ME (/showthread.php?tid=511910)



2 questions?? HELP ME - rockhopper - 08.05.2014

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 ??


Re: 2 questions?? HELP ME - rangerxxll - 08.05.2014

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



Re: 2 questions?? HELP ME - rockhopper - 08.05.2014

? i want a usage error for all cmds an example?


Re: 2 questions?? HELP ME - [..MonTaNa..] - 08.05.2014

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;
}



Re: 2 questions?? HELP ME - rockhopper - 08.05.2014

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"


Re: 2 questions?? HELP ME - [..MonTaNa..] - 08.05.2014

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;
}



Re: 2 questions?? HELP ME - rockhopper - 08.05.2014

ok thanks


Re: 2 questions?? HELP ME - rockhopper - 09.05.2014

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


Re: 2 questions?? HELP ME - Konstantinos - 09.05.2014

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 '%'



Re: 2 questions?? HELP ME - rockhopper - 09.05.2014

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