SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/01/2018, 08:53 AM   #1
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default help me dice command

I Have These Codes:

Code:
CMD:dicep(playerid, params[])
{
	new targetid, str[180], str2[180], bet;
	if(sscanf(params, "ui", targetid, bet)) return SCM(playerid, -1, "/dicep [playerid] [money]");
	if(targetid == INVALID_PLAYER_ID) return SCM(playerid, -1, "Player Isnt Connected.");
	new mymoney = (GetPlayerMoney(playerid));
	new targetmoney = (GetPlayerMoney(targetid));
	if(bet>mymoney) return SCM(playerid, -1, "You Dont Have That Amount Of Money.");
	if(bet>targetmoney) return SCM(playerid, -1, "He Dont Have Enough Money.");
	if(bet >= targetmoney)
	{
	    new pname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
	    GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
		format(str, sizeof(str), "Dice Sent.");
		format(str2, sizeof(str2), "[%i] %s Sent You Dice with %i .", playerid, pname, bet);
		SCM(playerid, -1, str);
		SCM(targetid, -1, str2);
	
	


		CMD:acceptdice(playerid, params[])
		{
			if(sscanf(params, "u", playerid)) return SCM(playerid, -1, "/acceptdice[id]");
		 	if(!sscanf(params, "u", playerid))
			{
	 			//new targetid, bet;

				new player1, player2;
				player1=random(7);
				player2=random(7);
				if(player1>player2)
				{
					new string[128];
					new string2[128];
					format(string, sizeof(string), "You win %i", bet);
					GivePlayerMoney(playerid, bet);
					GivePlayerMoney(targetid, -bet);
					format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
					SCM(playerid,Green , string2);
					SCM(playerid,Green , string);

				}
				if(player1<player2)
				{
					new string[128];
					new string2[128];
					format(string, sizeof(string), "You lose %i", bet);
					GivePlayerMoney(targetid, bet);
					GivePlayerMoney(playerid, -bet);
					format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
					SCM(playerid,0xCC0000 , string2);
					SCM(playerid,0xCC0000 , string);

				 }


		}
		}
	return 1;


}

And I Have These Errors:
Code:
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(504) : error 029: invalid expression, assumed zero
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(504) : error 017: undefined symbol "cmd_acceptdice"
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(504) : error 029: invalid expression, assumed zero
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(504) : fatal error 107: too many error messages on one line

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


4 Errors.

I Mean With this code :
example:
/dicep 1 500000 (player1 (id:0))
/accept dice 0 (player2(id:1)))


Please Help ME
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 08:58 AM   #2
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,080
Reputation: 126
Default Re: help me dice command

Be sure to make all commands end correctly, same goes for { } brackets.
Code:
CMD:dicep(playerid, params[])
{
	new targetid, str[180], str2[180], bet;
	if(sscanf(params, "ui", targetid, bet)) return SCM(playerid, -1, "/dicep [playerid] [money]");
	if(targetid == INVALID_PLAYER_ID) return SCM(playerid, -1, "Player Isnt Connected.");
	new mymoney = (GetPlayerMoney(playerid));
	new targetmoney = (GetPlayerMoney(targetid));
	if(bet>mymoney) return SCM(playerid, -1, "You Dont Have That Amount Of Money.");
	if(bet>targetmoney) return SCM(playerid, -1, "He Dont Have Enough Money.");
	if(bet >= targetmoney)
	{
	    new pname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
	    GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
		format(str, sizeof(str), "Dice Sent.");
		format(str2, sizeof(str2), "[%i] %s Sent You Dice with %i .", playerid, pname, bet);
		SCM(playerid, -1, str);
		SCM(targetid, -1, str2);
	}
	return 1;
}

CMD:acceptdice(playerid, params[])
{
	if(sscanf(params, "u", playerid)) return SCM(playerid, -1, "/acceptdice[id]");
 	if(!sscanf(params, "u", playerid))
	{
		new player1, player2;
		player1=random(7);
		player2=random(7);
	if(player1>player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You win %i", bet);
		GivePlayerMoney(playerid, bet);
		GivePlayerMoney(targetid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,Green , string2);
		SCM(playerid,Green , string);

	}
	if(player1<player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You lose %i", bet);
		GivePlayerMoney(targetid, bet);
		GivePlayerMoney(playerid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,0xCC0000 , string2);
		SCM(playerid,0xCC0000 , string);
	}
    return 1;
}
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 03/01/2018, 09:19 AM   #3
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: help me dice command

Quote:
Originally Posted by jasperschellekens View Post
Be sure to make all commands end correctly, same goes for { } brackets.
Code:
CMD:dicep(playerid, params[])
{
	new targetid, str[180], str2[180], bet;
	if(sscanf(params, "ui", targetid, bet)) return SCM(playerid, -1, "/dicep [playerid] [money]");
	if(targetid == INVALID_PLAYER_ID) return SCM(playerid, -1, "Player Isnt Connected.");
	new mymoney = (GetPlayerMoney(playerid));
	new targetmoney = (GetPlayerMoney(targetid));
	if(bet>mymoney) return SCM(playerid, -1, "You Dont Have That Amount Of Money.");
	if(bet>targetmoney) return SCM(playerid, -1, "He Dont Have Enough Money.");
	if(bet >= targetmoney)
	{
	    new pname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
	    GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
		format(str, sizeof(str), "Dice Sent.");
		format(str2, sizeof(str2), "[%i] %s Sent You Dice with %i .", playerid, pname, bet);
		SCM(playerid, -1, str);
		SCM(targetid, -1, str2);
	}
	return 1;
}

CMD:acceptdice(playerid, params[])
{
	if(sscanf(params, "u", playerid)) return SCM(playerid, -1, "/acceptdice[id]");
 	if(!sscanf(params, "u", playerid))
	{
		new player1, player2;
		player1=random(7);
		player2=random(7);
	if(player1>player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You win %i", bet);
		GivePlayerMoney(playerid, bet);
		GivePlayerMoney(targetid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,Green , string2);
		SCM(playerid,Green , string);

	}
	if(player1<player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You lose %i", bet);
		GivePlayerMoney(targetid, bet);
		GivePlayerMoney(playerid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,0xCC0000 , string2);
		SCM(playerid,0xCC0000 , string);
	}
    return 1;
}
i think you dont understood my code
i want /acceptdice accept /dicep
if you know how to please help me!!
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 09:45 AM   #4
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,080
Reputation: 126
Default Re: help me dice command

Quote:
Originally Posted by Osamakurdi View Post
i think you dont understood my code
i want /acceptdice accept /dicep
if you know how to please help me!!
Check at the code i posted. I literally fixed the error for you.
Your code would work already but you might want to add the things i marked red.

Code:
new RequestDiceBetting[MAX_PLAYERS];
 // on top of your script.

CMD:dicep(playerid, params[])
{
	new targetid, str[180], str2[180], bet;
	if(sscanf(params, "ui", targetid, bet)) return SCM(playerid, -1, "/dicep [playerid] [money]");
	if(targetid == INVALID_PLAYER_ID) return SCM(playerid, -1, "Player Isnt Connected.");
	new mymoney = (GetPlayerMoney(playerid));
	new targetmoney = (GetPlayerMoney(targetid));
	if(bet>mymoney) return SCM(playerid, -1, "You Dont Have That Amount Of Money.");
	if(bet>targetmoney) return SCM(playerid, -1, "He Dont Have Enough Money.");
	if(bet >= targetmoney)
	{
	    new pname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
	    GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
		format(str, sizeof(str), "Dice Sent.");
		format(str2, sizeof(str2), "[%i] %s Sent You Dice with %i .", playerid, pname, bet);
		SCM(playerid, -1, str);
		SCM(targetid, -1, str2);
		ReqeustDiceBetting[playerid] = 1;
	}
	return 1;
}

CMD:acceptdice(playerid, params[])
{
	if(sscanf(params, "u", playerid)) return SCM(playerid, -1, "/acceptdice[id]");
	if(ReqeustDiceBetting[u] == 0) return SCM(playerid, -1, "Player did not send a dice request.");
	ReqeustDiceBetting[u] = 0;
 	if(!sscanf(params, "u", playerid))
	{
		new player1, player2;
		player1=random(7);
		player2=random(7);
	if(player1>player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You win %i", bet);
		GivePlayerMoney(playerid, bet);
		GivePlayerMoney(targetid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,Green , string2);
		SCM(playerid,Green , string);

	}
	if(player1<player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You lose %i", bet);
		GivePlayerMoney(targetid, bet);
		GivePlayerMoney(playerid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,0xCC0000 , string2);
		SCM(playerid,0xCC0000 , string);
	}
    return 1;
}
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 03/01/2018, 09:52 AM   #5
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: help me dice command

Quote:
Originally Posted by jasperschellekens View Post
Check at the code i posted. I literally fixed the error for you.
Your code would work already but you might want to add the things i marked red.

Code:
new RequestDiceBetting[MAX_PLAYERS];
 // on top of your script.

CMD:dicep(playerid, params[])
{
	new targetid, str[180], str2[180], bet;
	if(sscanf(params, "ui", targetid, bet)) return SCM(playerid, -1, "/dicep [playerid] [money]");
	if(targetid == INVALID_PLAYER_ID) return SCM(playerid, -1, "Player Isnt Connected.");
	new mymoney = (GetPlayerMoney(playerid));
	new targetmoney = (GetPlayerMoney(targetid));
	if(bet>mymoney) return SCM(playerid, -1, "You Dont Have That Amount Of Money.");
	if(bet>targetmoney) return SCM(playerid, -1, "He Dont Have Enough Money.");
	if(bet >= targetmoney)
	{
	    new pname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
	    GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
		format(str, sizeof(str), "Dice Sent.");
		format(str2, sizeof(str2), "[%i] %s Sent You Dice with %i .", playerid, pname, bet);
		SCM(playerid, -1, str);
		SCM(targetid, -1, str2);
		ReqeustDiceBetting[playerid] = 1;
	}
	return 1;
}

CMD:acceptdice(playerid, params[])
{
	if(sscanf(params, "u", playerid)) return SCM(playerid, -1, "/acceptdice[id]");
	if(ReqeustDiceBetting[u] == 0) return SCM(playerid, -1, "Player did not send a dice request.");
	ReqeustDiceBetting[u] = 0;
 	if(!sscanf(params, "u", playerid))
	{
		new player1, player2;
		player1=random(7);
		player2=random(7);
	if(player1>player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You win %i", bet);
		GivePlayerMoney(playerid, bet);
		GivePlayerMoney(targetid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,Green , string2);
		SCM(playerid,Green , string);

	}
	if(player1<player2)
	{
		new string[128];
		new string2[128];
		format(string, sizeof(string), "You lose %i", bet);
		GivePlayerMoney(targetid, bet);
		GivePlayerMoney(playerid, -bet);
		format(string2, sizeof(string2), "You rolled %i %i", player1, player2);
		SCM(playerid,0xCC0000 , string2);
		SCM(playerid,0xCC0000 , string);
	}
    return 1;
}
Thanks For Helping me but i have these errors .. :*
Code:
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : error 017: undefined symbol "ReqeustDiceBetting"
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : warning 215: expression has no effect
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : error 001: expected token: ";", but found "]"
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : error 029: invalid expression, assumed zero
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : fatal error 107: too many error messages on one line

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


4 Errors.
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 09:53 AM   #6
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,080
Reputation: 126
Default Re: help me dice command

Quote:
Originally Posted by Osamakurdi View Post
Thanks For Helping me but i have these errors .. :*
Code:
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : error 017: undefined symbol "ReqeustDiceBetting"
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : warning 215: expression has no effect
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : error 001: expected token: ";", but found "]"
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : error 029: invalid expression, assumed zero
C:\Users\Kurdi's\Desktop\samp037_svr_R2-1-1_win32\gamemodes\FirstCode.pwn(712) : fatal error 107: too many error messages on one line

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


4 Errors.
new RequestDiceBetting[MAX_PLAYERS];
// add on top of your script.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 03/01/2018, 09:59 AM   #7
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: help me dice command

Quote:
Originally Posted by jasperschellekens View Post
new RequestDiceBetting[MAX_PLAYERS];
// add on top of your script.
Where Do You mean? im sorry for stress ..
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 10:03 AM   #8
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,080
Reputation: 126
Default Re: help me dice command

Quote:
Originally Posted by Osamakurdi View Post
Where Do You mean? im sorry for stress ..
under/below all your define's and enums.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 03/01/2018, 05:51 PM   #9
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: help me dice command

Quote:
Originally Posted by jasperschellekens View Post
under/below all your define's and enums.
Thanks +REP
Osamakurdi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/dice command Osamakurdi Scripting Help 6 21/12/2017 11:49 AM
Dice command. GabiXx Scripting Help 7 26/12/2015 11:57 AM
[Tutorial] How to Make a Dice Command kosa451 Tutorials 13 04/09/2014 07:46 PM
command /dice. capsator10 Scripting Help 30 14/08/2014 06:28 PM
Dice command friezakinght Scripting Help 2 10/07/2014 02:01 PM


All times are GMT. The time now is 04:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.