.amx Size
#4

It's quite alright, here, i'll give you an example.. Say you wanted to just send a message to everyone saying that someone has typed a command.

(Note: I use ZCMD, as you're a beginner, you probably made your command using OnPlayerCommandText, but it's still the base that counts.)

Correct:
pawn Code:
zcmd(test, playerid, params[])
{
    new string[128];
    new name;
    GetPlayerName(playerid, name, sizeof(name));
    SendClientMessageToAll(playerid, white, "%s has typed \"/TEST\"!", name); // The \" is used to make Quotation marks in-game, as using just " " would close your SendClientMessage.
    return 1;
}
Incorrect:
pawn Code:
zcmd(test, playerid, params[])
{
    new string[256];
    new name;
    GetPlayerName(playerid, name, sizeof(name));
    SendClientMessageToAll(playerid, white, "%s has typed \"/TEST\"!", name);
    return 1;
}
As i don't think you would need 256 cells in order to just tell everyone that someone has typed a command.

Also, consider breaking away from Strtok, and things like that, ZCMD and DCMD are the most effecient commands, and they're also very very powerful.

Example:

/SetHP using STRTOK = 19 Lines:
pawn Code:
if(strcmp(cmd, "/sethealth", true)==0||strcmp(cmd, "/sethp", true)==0)
    {
        new varhp;
        tmp=strtok(cmdtext,idx);
        if(strlen(tmp)==0) return SendClientMessage(playerid, COLOR_LB, "Syntax: /SetHP <Player ID/Part of Name> <Amount>");
        player = ReturnUser(tmp);
        tmp=strtok(cmdtext,idx);
        if(strlen(tmp)==0) return SendClientMessage(playerid, COLOR_LB, "Syntax: /SetHP <Player ID/Part of Name> <Amount>");
        varhp=strval(tmp);
        if(player != INVALID_PLAYER_ID)
        {
            if(PlayerInfo[playerid][pAdmin] >= 2)
            {
                SetPlayerHealth(player, varhp);
}
            else return SendClientMessage(playerid, COLOR_RED, "(Error): You're not an administrator! (Error Code: 45)");
}
        else return SendClientMessage(playerid, COLOR_RED, "(Error): Player does not exist.");
        return 1;
    }
/SetHP using ZCMD = 17 Lines.
pawn Code:
zcmd(sethp, playerid, params[])
{
    new player,hp;
    if(!sscanf(params, "ui", player, hp))
    {
        if(player != INVALID_PLAYER_ID)
        {
            if(PlayerInfo[playerid][pAdmin] >= 2)
            {
                SetPlayerHealth(player, hp);
            }
            else return SendClientMessage(playerid, red, "(Error): You're not an administrator!");
        }
        else return SendClientMessage(playerid, red, "(Error): Player does not exist.");
    }
    else return SendClientMessage(playerid, lb, "Syntax: /SetHP <Player ID/Part of Name> <Amount>");
    return 1;
}
Reply


Messages In This Thread
.amx Size - by UberSocks - 10.10.2009, 01:37
Re: .amx Size - by (.Aztec); - 10.10.2009, 01:50
Re: .amx Size - by UberSocks - 10.10.2009, 01:52
Re: .amx Size - by (.Aztec); - 10.10.2009, 01:57
Re: .amx Size - by (.Aztec); - 10.10.2009, 02:13
Re: .amx Size - by UberSocks - 10.10.2009, 02:23
Re: .amx Size - by (.Aztec); - 10.10.2009, 02:25
Re: .amx Size - by UberSocks - 10.10.2009, 02:27
Re: .amx Size - by Simon - 10.10.2009, 02:32
Re: .amx Size - by _Vortex - 10.10.2009, 02:34
Re: .amx Size - by Gamer_Z - 06.02.2012, 13:35
Re: .amx Size - by Rac3r - 16.03.2012, 10:25

Forum Jump:


Users browsing this thread: 2 Guest(s)