Help With Switch & DCMD
#1

So yeah, Im trying to make a command where it allow you to type /dance 1-4. But when I try my command below it gives SERVER: UNKNOWN COMMAND message. I added the dcmd part in OnPlayerCommandText so thats not the problem.
Also when I tried it earlier it did the first anim even if I did /dance 4.
So I'm not 100% sure about how I should do commands like this, any help would be extremly helpfull!

pawn Код:
dcmd_dance(playerid,params[])
{
   
    if(!strval(params)) return SendClientMessage(playerid, RED, "Usage: /dance 1-4");
    switch(strval(params))
    {
    case 0: SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE1);
    case 1: SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE2);
    case 2: SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE3);
    case 3: SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE4);
    }
    return 1;
}
Thanks, [03]Garsino.
Reply
#2

why dont u just get http://forum.sa-mp.com/index.php?topic=143623.0 it's better than u making cmds
Reply
#3

Quote:
Originally Posted by WolfeX
why dont u just get http://forum.sa-mp.com/index.php?topic=143623.0 it's better than u making cmds
1) I prefer DCMD because it's faster.
2) I don't feel like making multiple commands for /dance 1-4 when I could make it with a simple switch and case...
3) I got other commands like this that it not in that thread...
Reply
#4

Dunno if this will work, u maybe forgot brackets, try it
Didnt test it hope it works for you, Peace
Код:
dcmd_dance(playerid,params[])
{
	
	if(!strval(params)) return SendClientMessage(playerid, RED, "Usage: /dance 1-4");
 	switch(strval(params))
 	{
	case 0: 
     {
     SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE1);
     }
	case 1: 
     {
     SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE2);
     }
	case 2: 
     {
     SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE3);
     }
	case 3: 
     {
     SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE4);
	}
	return 1;
}
Reply
#5

Quote:
Originally Posted by [03
Garsino ]
Quote:
Originally Posted by WolfeX
why dont u just get http://forum.sa-mp.com/index.php?topic=143623.0 it's better than u making cmds
1) I prefer DCMD because it's faster.
2) I don't feel like making multiple commands for /dance 1-4 when I could make it with a simple switch and case...
3) I got other commands like this that it not in that thread...
for fastest commands use zcmd+sscanf,as other ppl allways say me that and i learn and its perfect :P and its easy to script
Reply
#6

for such commands i am using dcmd and the sscanf-include, maybe it helps a bit?
Код:
dcmd_Dance(playerid,params[])
{
	new Style=playerid;
	if (sscanf(params,"d",Style))
	{
		SendClientMessage(playerid,MSGCOMM_COLOR, "Usage: \"/Dance <Style (1-4)>\"");
	}
	else
	{
		if(Style<0 || Style>4)
		{
			new string[64];
			format(string,sizeof(string),"Dance Style %d not available. Usage: \"/Dance <Style (1-4)>\"",Style);
			SendClientMessage(BailID,0xff5555ff,string);
			return 1;
		}
		if (Style==1)
		{
			SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE1);
			return 1;
		}
		else if (Style==2)
		{
			SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE2);
			return 1;
		}
		else if (Style==3)
		{
			SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE3);
			return 1;
		}
		else if (Style==4)
		{
			SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE4);
			return 1;
		}
	}
	return 1;
}
Reply
#7

Yeah, I used ZCMD but hard a hard time converting all my commands. And after some commands were ZCMD and some were not my other commands wouldn't work(not dcmd).
Reply
#8

listen to ******

EDIT: just make commads to zcmd+sscanf as i did and i will say u again it easyer to script
Reply
#9

Quote:
Originally Posted by [03
Garsino ]
Yeah, I used ZCMD but hard a hard time converting all my commands.
It's worth it.
Reply
#10

None of the code worked.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)