[SOLVED]Need help with DCMD.
#1

Hello, today I have been working a little bit to learn how to code with DCMD. I got to the point where it didn't make sense to me, since I just started, so this is my code.

Lines 91-126
pawn Код:
dcmd_kick(playerid, const params[])
{
    if(IsPlayerAdmin(playerid))
    {
      new giveplayerid;
     
      if(!strlen(params))
      {
        SendClientMessage(playerid, 0xFF0000FF, "Invalid Params ! > '/kick ID'");
        return 1;
        }
        giveplayerid = strval(params);
           
        if(IsPlayerConnected(giveplayerid))
            {
                new string[39];
                format(string, sizeof(string), "You have kicked ID %i", playerid);
                SendClientMessage(playerid, 0xFF0000FF, string);
                format(string, sizeof(string), "An admin has kicked ID %i from the server", playerid);
                SendClientMessageToAll(0xFF0000FF, string);
                SendClientMessage(playerid, 0xFF0000FF, "You have been kicked from the server!");
                kick(giveplayerid);
                {
                else
                {
                  SendClientMessage(playerid, 0xFFFFFFFF, "[server] Error: Player is not active!");
                  return 1;
                }
        {
        else
        {
          SendClientMessage(playerid, 0xFF0000FF, "You are not an admin with the required level!");
            return 1;
            }
        }
    }
}
127 - 162
pawn Код:
dcmd_ban(playerid, const params[])
{
    if(IsPlayerAdmin(playerid))
    {
      new giveplayerid;
     
      if(!strlen(params))
        {
          SendClientMessage(playerid, 0xFF0000FF, "Invalid Params ! > ' /ban ID '");
          return 1;
        }
        giveplayerid = strval(params);
       
        if(IsPlayerConnected(giveplayerid))
        {
          new string[36];
          format(string, sizeof(string), "You have banned ID %i", playerid);
          SendClientMessage(playerid, 0xFF0000FF, string);
          format(string, sizeof(string), "ID %i has been banned from the server!", playerid);
          SendClientMessage(playerid, 0xFF0000FF, string);
          SendClientMessage(playerid, 0xFF0000FF, "You have been banned from the server!");
          Ban(giveplayerid);
          return 1;
        {
        else
        {
          SendClientMessage(playerid, 0xFF0000FF, "[server] Error: Player is not active!");
          return 1;
        }
        {
        else
        {
          SendClientMessage(playerid, 0xFF0000FF, "You are not an admin with the required level!");
          return 1;
        }
    }
}
as you can see, I was working to create a /ban and /kick command, but not have so many errors.

Errors :
Код:
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(112) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(117) : warning 225: unreachable code
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(117) : warning 217: loose indentation
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(118) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(127) : warning 217: loose indentation
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(127) : error 017: undefined symbol "dcmd_ban"
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(127) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(127) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\Desktop\SAMPSERVER\gamemodes\RolePlayingServerV1.pwn(127) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
As you can see, what I was attempting to do was, When a player tries to kick another player, and that player is not active, it sends the message, and if the player (kicker) is not an admin, and he tries to kick another player, he should get the other message saying he is not the admin with the required level.

Any help would be appreciated.
Hiitch.

P.s. Sorry for the bad indentation, comes when I copy / paste from pawno to here.
Reply
#2

Код:
(117) : warning 217: loose indentation
(127) : warning 217: loose indentation
Those warnings is showing cause of bad indentation.
http://forum.sa-mp.com/index.php?topic=61893

And change
pawn Код:
const params[]
to
pawn Код:
params[]
in both dcmd commands.

If you still got errors, please show us one more time after fixing these things ^

EDIT:
Heres the "fixed" code - http://pastebin.com/m312cbaa0
Not compiled, but shouldn't return any warnings/errors
Reply
#3

yeah he is right and try to put this on the top of your script .It may help you
Код:
#pragma tabsize 0
EDIT:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

dcmd(ban,3,cmdtext);
return 1;
}
return 0;
}
Reply
#4

Quote:
Originally Posted by DarkShootah
im not sure but did you add?
pawn Код:
//ban
dcmd(ban, 4, cmdtext);
//kick
dcmd(kick, 5, cmdtext);
Since when "ban" has 4 characters and "kick" 5?

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  dcmd(ban, 3, cmdtext);
  dcmd(kick, 4, cmdtext);
  return false;
}
Reply
#5

> lrZ^ aka LarzI : Thank you for the fixing the code, I had a couple of loose indentations, but I fixed them easily.

> Don Correlli : Thanks for telling me to put the dcmd(ban,3,cmdtext); I forgot where to put that.

Reply
#6

No problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)