dcmd little help :D
#1

Hi all! I am new in the forums and new in using dcmd. Until now I was using zcmd and I have some problems. These are "some" of my zcmd cmds (only few, I rebooted my PC two days before and lost about 60 anims and cmds )

Код:
COMMAND:pay(playerid, params[])
{
	new targetid, value;
	if (sscanf(params, "ui", targetid, value)) SendClientMessage (playerid, 0xBDB76BAA, "ERROR: /pay [targetid] [value]");
	else if (value > GetPlayerMoney(playerid)) SendClientMessage (playerid, 0xBDB76BAA, "You can't afford that much");
	else if (targetid == INVALID_PLAYER_ID) SendClientMessage (playerid, 0xBDB76BAA, "Player Not Found");
	else
	{
	    GivePlayerMoney (playerid, 0- value);
	    GivePlayerMoney (targetid, value);
	    SendClientMessage (playerid, 0xBDB76BAA, "You have sent %i to %u");
	    SendClientMessage (playerid, 0xBDB76BAA, "You received %i from %u");
	}
	return 1;
}
This is the most easy cmd... now, can you help me by giving me some examples on dcmd? (this cmd and anims pls)
Reply
#2

why did you downgrade from ZCMD to DCMD unless you didn't crate this command.
Reply
#3

Umm... I am looking for some tutorials of dcmd man... this was just an example. Have a look at these:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(heal, 4, cmdtext);
	return 0;
}

dcmd_heal(playerid, params[])
{
	new
		id;
	if (sscanf(params, "u", id)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /heal [playerid]");
	if (IsPlayerAdmin(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You have no access to this command");
	else if (id == INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
	else
	{
		SetPlayerHealth (id, 100.0);
		SendClientMessage (id, 0x33CCFFAA, "You have been healed");
		SendClientMessage (playerid, 0x33CCFFAA, "Player healed");
	}
	return 1;
}

{
	dcmd(pay, 3, cmdtext);
	return 0;
}
dcmd_pay (playerid, params[])
{
	new targetid;
	if (sscanf(params, "ui", targetid, value)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /pay [playerid] [value]");
	else if (targetid = INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
	else if (value > GetPlayerMoney(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You can't afford that much");
	else
	{
	    GivePlayerMoney (targetid, value);
	    GivePlayerMoney (playerid, 0- value);
	    SendClientMessage (targetid, 0x33CCFFAA, "%u sent you %i");
	    SendClientMessage (playerid, 0x33CCFFAA, "You succesfully sent %i to %u);
	}
	return 1;
}
Finally it says:

Код:
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(129) : error 055: start of function body without function header
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(130) : error 010: invalid function or declaration
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(131) : error 010: invalid function or declaration
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(283) : warning 203: symbol is never used: "dcmd_pay"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Any help Pls...
Reply
#4

All those 'dcmd(' stuff must be under OnPlayerCommandText

Quote:

{
dcmd(pay, 3, cmdtext);
return 0;
}

It ends a function, and then you open a bracket without any callback/function name. Remove that whole text (in my quote) and add the dcmd(pay, 3, cmdtext) under OnPlayerCommandText (IN that callback, below the other dcmd(*)
Reply
#5

umm... can you be more clear? post me an example of my "resolved" cmds...

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(heal, 4, cmdtext);
	return 0;
}

dcmd_heal(playerid, params[])
{
	new
		id;
	if (sscanf(params, "u", id)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /heal [playerid]");
	if (IsPlayerAdmin(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You have no access to this command");
	else if (id == INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
	else
	{
		SetPlayerHealth (id, 100.0);
		SendClientMessage (id, 0x33CCFFAA, "You have been healed");
		SendClientMessage (playerid, 0x33CCFFAA, "Player healed");
	}
	return 1;
}

{
	dcmd(pay, 3, cmdtext);
	return 0;
}
dcmd_pay (playerid, params[])
{
	new targetid;
	if (sscanf(params, "ui", targetid, value)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /pay [playerid] [value]");
	else if (targetid = INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
	else if (value > GetPlayerMoney(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You can't afford that much");
	else
	{
	    GivePlayerMoney (targetid, value);
	    GivePlayerMoney (playerid, 0- value);
	    SendClientMessage (targetid, 0x33CCFFAA, "%u sent you %i");
	    SendClientMessage (playerid, 0x33CCFFAA, "You succesfully sent %i to %u);
	}
	return 1;
}
Reply
#6

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(heal, 4, cmdtext);
        dcmd(pay, 3, cmdtext);
    return 0;
}

dcmd_heal(playerid, params[])
{
    new
        id;
    if (sscanf(params, "u", id)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /heal [playerid]");
    if (IsPlayerAdmin(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You have no access to this command");
    else if (id == INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
    else
    {
        SetPlayerHealth (id, 100.0);
        SendClientMessage (id, 0x33CCFFAA, "You have been healed");
        SendClientMessage (playerid, 0x33CCFFAA, "Player healed");
    }
    return 1;
}

dcmd_pay (playerid, params[])
{
    new targetid;
    if (sscanf(params, "ui", targetid, value)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /pay [playerid] [value]");
    else if (targetid = INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
    else if (value > GetPlayerMoney(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You can't afford that much");
    else
    {
        GivePlayerMoney (targetid, value);
        GivePlayerMoney (playerid, 0- value);
        SendClientMessage (targetid, 0x33CCFFAA, "%u sent you %i");
        SendClientMessage (playerid, 0x33CCFFAA, "You succesfully sent %i to %u);
    }
    return 1;
}
btw please use pawn BB codes

[ pawn ]{CODE}[ /pawn ] (without the spaces)
And I reccomend you to use ZCMD. you can simpy convert dcmd to zcmd.
Press CTRL+H and replace 'dcmd_' for 'CMD:' . (yes to all) Remove the dcmd(*) stuff from OnPlayerCommandText. That's it :P (and dont forget adding #include <zcmd>)
Reply
#7

lol thnx... in my actual server they recommend me dcmd so I am going to use it.. now let's see..

pawn Код:
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(110) : warning 217: loose indentation
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(111) : warning 217: loose indentation
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(133) : error 017: undefined symbol "value"
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(134) : warning 211: possibly unintended assignment
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(135) : error 017: undefined symbol "value"
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(138) : error 017: undefined symbol "value"
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(139) : error 017: undefined symbol "value"
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(141) : error 037: invalid string (possibly non-terminated string)
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(141) : error 017: undefined symbol "You"
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(141) : error 017: undefined symbol "succesfully"
C:\Program Files\GTA San Andreas\server\filterscripts\dcmdtest.pwn(141) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


8 Errors.
shit... nvm i am going to use ZCMD now on. there, my zcmd:

pawn Код:
COMMAND:heal(playerid, params[])
{
    new
        id;
    if (sscanf(params, "u", id)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /heal [playerid]");
    if (IsPlayerAdmin(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You have no access to this command");
    else if (id == INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
    else
    {
        SetPlayerHealth (id, 100.0);
        SendClientMessage (id, 0x33CCFFAA, "You have been healed");
        SendClientMessage (playerid, 0x33CCFFAA, "Player healed");
    }
    return 1;
}

COMMAND:pay(playerid, params[])
{
    new targetid, value;
    if (sscanf(params, "ui", targetid, value)) SendClientMessage (playerid, 0x33CCFFAA, "Usage: /pay [playerid] [value]");
    else if (targetid == INVALID_PLAYER_ID) SendClientMessage (playerid, 0x33CCFFAA, "Player not found");
    else if (value > GetPlayerMoney(playerid)) SendClientMessage (playerid, 0x33CCFFAA, "You can't afford that much");
    else
    {
        GivePlayerMoney (targetid, value);
        GivePlayerMoney (playerid, 0- value);
        SendClientMessage (targetid, 0x33CCFFAA, "%u sent you %i");
        SendClientMessage (playerid, 0x33CCFFAA, "You succesfully sent %i to %u");
    }
    return 1;
}
pawn Код:
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
Reply
#8

I love ZCMD. No errors and warnings xD
Reply
#9

now, can you help me with something? i need some help about the anims. i want the info's about anims library, i am too lazy to find them

/drunk anim (with library etc etc)
/drink 1,2
/piss
/wank
/robman

etc... AND finally... some little help

a /me cmd (in zcmd ofc )
Reply
#10

the /me command (no sscanf because it's one param)

pawn Код:
CMD:me(playerid, params[])
{
    new str[128], pName[MAX_PLAYER_NAME];
    if(!strlen(params[0]) || strlen(params[0] > 75)
        return SendClientMessage(playerid, 0xFF0000AA, "The length must be above 0 and below 76!");
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(str, 128, "* %s %s", pName, params[0]);
    SendClientMessageToAll(0x00FF00AA, str);
    return 1;
}
About the anims: Try finding them in this script: https://sampforum.blast.hk/showthread.php?tid=128863
Just look in other scripts
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)