4 Newbies
#1

Well, I saw many newbies need it,

How to create "Strcmp" command ?

Strcmp command always being show'd under the callback:
pawn Код:
public OnPlayerCommand(playerid, cmdtext[])
In this thread, We will try, The "/kill" command.

This is the whole Script:
pawn Код:
/*Line 1*/public OnPlayerCommand(playerid, cmdtext[])
/*Line 2*/{
/*Line 3*/    if(strcmp("/kill", cmdtext, true) == 0)
/*Line 4*/    {
/*Line 5*/        SetPlayerHealth(playerid, 0.0);
/*Line 6*/        SendClientMessage(playerid, 0x00000000, "{FFFFFF}You have been {FF0000}died!");
/*Line 7*/        return 1;
/*Line 8*/    }
/*Line 9*/    return SendClientMessage(playerid, 0x00000000, "{FFFFFF}Wrong {FFFF00}Command");
/*Line 10*/}
Explain:
Line 1 - That our Callback
Line 2 - We open the callback
Line 3 - We ask ourselves, What happened if he type the command kill ?
Line 4 - We open the command
Line 5 - We are killing him as we set his health to 0
Line 6 - We are sending the player a message with colour Embeding "You have been died!"
Line 7 - If all that happened, Return that all what happened is TRUE
Line 8 - We are closing the command
Line 9 - If the player sending "Unknown command" it will say "Wrong Command"
Line 10 - We are closing the callback.

Regards,

InterRP Team
Reply
#2

Is this a question or a tutorial? AFAIT, this should be posted in the tutorial section.
Reply
#3

i guess it should be like this

pawn Код:
public OnPlayerCommand(playerid, cmdtext[])
    {
    if(strcmp("/kill", cmdtext, true) == 0)
    {
        SetPlayerHealth(playerid, 0.0);
        SendClientMessage(playerid, 0x00000000, "{FFFFFF}You have been {FF0000}died!");
        else
        return SendClientMessage(playerid, 0x00000000, "{FFFFFF}Wrong {FFFF00}Command");
        return 1;
}
or something like that You need "else" i think so :/
Reply
#4

This is a tutorial, But newbies won't look there.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)