SA-MP Forums Archive
Bet command - 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: Bet command (/showthread.php?tid=85398)



Bet command - Viktor_Burns - 07.07.2009

Hi there, im working on my bet command.
This is what I got so far:

pawn Код:
if(strcmp("/bet", cmdtext, true) == 0)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [amount] [color (red or black)]");
    return 1;
    }
    new rand = random(2);
    new amount;
    amount = strval(tmp);
    if(rand >= 0)
    if(strcmp(tmp, "red", true) == 0)
    {
    GivePlayerMoney(playerid, amount);
    format(string, sizeof(string), "RED WINS: You win %d dollars !",amount);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
    }
    else if(strcmp(tmp, "black", true) == 0)
    {
    GivePlayerMoney(playerid, -amount);
    format(string, sizeof(string), "BLACK WINS: You lose %d dollars !",amount);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
    }
    if(rand >=1)
    if(strcmp(tmp, "black", true) == 0)
    {
    GivePlayerMoney(playerid, amount);
    format(string, sizeof(string), "BLACK WINS: You win %d dollars !",amount);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
    }
    else if(strcmp(tmp, "red", true) == 0)
    {
    GivePlayerMoney(playerid, -amount);
    format(string, sizeof(string), "RED WINS: You lose %d dollars !",amount);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
    }
}
It compiles fine, but the problem is, when I type for example /bet 1000 red ingame, it gives me UNKNOWN command, anyone out there who knows the solution?

thx in advance


Re: Bet command - yom - 07.07.2009

Use sscanf.


Re: Bet command - Viktor_Burns - 07.07.2009

Quote:
Originally Posted by 0rb
Use sscanf.
Be more specific please


Re: Bet command - refshal - 07.07.2009

https://sampwiki.blast.hk/wiki/Sscanf


Re: Bet command - Viktor_Burns - 07.07.2009

I already got that. How to use it?


Re: Bet command - refshal - 07.07.2009

Search.


Re: Bet command - Viktor_Burns - 07.07.2009

Quote:
Originally Posted by еddy
Search.
I can't find how to use SSCANF in this case.
I already searched but didn't find anything that helped


Re: Bet command - yom - 07.07.2009

Here you have some infos about sscanf: https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf


Re: Bet command - Viktor_Burns - 07.07.2009

Still didn't get it how I should use it here though.


Re: Bet command - Jefff - 07.07.2009

You use strtok so u cant use cmdtext only cmd
Код:
if(strcmp(cmd,"/bet", true) == 0)
{
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [amount] [color (red or black)]");
	new amount = strval(tmp);
	tmp = strtok(cmdtext, idx);
	new rand = random(2);
	if(!rand)
	{
		if(strcmp(tmp, "red", true) == 0)
		{
			GivePlayerMoney(playerid, amount);
			format(string, sizeof(string), "RED WINS: You win %d dollars !",amount);
			SendClientMessage(playerid, COLOR_WHITE, string);
		}
		else if(strcmp(tmp, "black", true) == 0)
		{
			GivePlayerMoney(playerid, -amount);
			format(string, sizeof(string), "BLACK WINS: You lose %d dollars !",amount);
			SendClientMessage(playerid, COLOR_WHITE, string);
		}
	}else{
		if(strcmp(tmp, "black", true) == 0)
		{
			GivePlayerMoney(playerid, amount);
			format(string, sizeof(string), "BLACK WINS: You win %d dollars !",amount);
			SendClientMessage(playerid, COLOR_WHITE, string);
		}
		else if(strcmp(tmp, "red", true) == 0)
		{
			GivePlayerMoney(playerid, -amount);
			format(string, sizeof(string), "RED WINS: You lose %d dollars !",amount);
			SendClientMessage(playerid, COLOR_WHITE, string);
		}
	}
	return 1;
}
:>