PDA

View Full Version : 2 questions?? HELP ME


rockhopper
08/05/2014, 07:00 AM
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 ??

rangerxxll
08/05/2014, 07:06 AM
Use the OnPlayerCommandPerformed callback with zeex's zcmd.
if(!success) return SCM(playerid,COLOR, "Please use /help for available commands.");

rockhopper
08/05/2014, 07:13 AM
? i want a usage error for all cmds an example?

[..MonTaNa..]
08/05/2014, 07:45 AM
Can you explain more on #1?

An example for #2.


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

rockhopper
08/05/2014, 07:54 AM
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"

[..MonTaNa..]
08/05/2014, 08:04 AM
Use the OnPlayerCommandPerformed callback with zeex's zcmd.
if(!success) return SCM(playerid,COLOR, "Please use /help for available commands.");


This will probably solve #1 :)

or:


public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success) SendClientMessage(playerid, -1, "Unknown command. Type /cmds for commands.");
return 1;
}

rockhopper
08/05/2014, 08:13 AM
ok thanks

rockhopper
09/05/2014, 01:56 PM
hey another doubt on #2 is that a order %s first and %d following that?

Konstantinos
09/05/2014, 02:04 PM
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.



Specifier
Meaning


%i
Integer (whole number)


%d
Integer (whole number).


%s
String


%f
Floating-point number (Float: tag)


%c
ASCII character


%x
Hexadecimal number


%b
Binary number


%%
Literal '%'

rockhopper
09/05/2014, 02:36 PM
ohh ok so he used %s for Name and %d for playerid
Thanks +rep