SA-MP Forums Archive
Help With Switch & DCMD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help With Switch & DCMD (/showthread.php?tid=119481)



Help With Switch & DCMD - [03]Garsino - 08.01.2010

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.


Re: Help With Switch & DCMD - WolfeX - 08.01.2010

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


Re: Help With Switch & DCMD - [03]Garsino - 08.01.2010

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...


Re: Help With Switch & DCMD - bajskorv123 - 08.01.2010

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;
}



Re: Help With Switch & DCMD - Lajko1 - 08.01.2010

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


Re: Help With Switch & DCMD - Babul - 08.01.2010

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;
}



Re: Help With Switch & DCMD - [03]Garsino - 08.01.2010

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).


Re: Help With Switch & DCMD - Lajko1 - 08.01.2010

listen to ******

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


Re: Help With Switch & DCMD - Correlli - 08.01.2010

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


Re: Help With Switch & DCMD - [03]Garsino - 08.01.2010

None of the code worked.