SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 03/01/2018, 05:40 PM   #1
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default CMD content save. +REP

I have cmd looks like:
/dice playerid money
And i have another cmd :
/acceptdice playerid money
What code that check if money of acceptdice
=money of dice??
Please help me
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 05:52 PM   #2
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,193
Reputation: 420
Default Re: CMD content save. +REP

put a new dicemoney; on top of the script and do dicemoney = money in the cmd then go to the accepted player in the cmd and check if(GetPlayerMoney(playerid) == dicemoney) ... etc
__________________
Quote:
Originally Posted by Andy
My anti cheat is still relevant *puts shades on* https://github.com/RogueDrifter/Anti_cheat_pack

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link

RogueDrifter is offline   Reply With Quote
Old 03/01/2018, 05:57 PM   #3
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: CMD content save. +REP

I will try it tomorrow cuz im using phone now if it works I'll give you +REP thx in advanced
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 06:05 PM   #4
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,506
Reputation: 305
Default Re: CMD content save. +REP

The fore-mentioned post is just an idea of how you could do it, but if two players executed the same command, then it'll overwrite the previous value and for that you'll need to make an array with MAX_PLAYERS as the buffer/ array size.
Logic_ is offline   Reply With Quote
Old 03/01/2018, 06:11 PM   #5
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: CMD content save. +REP

Quote:
Originally Posted by Logic_ View Post
The fore-mentioned post is just an idea of how you could do it, but if two players executed the same command, then it'll overwrite the previous value and for that you'll need to make an array with MAX_PLAYERS as the buffer/ array size.
This is code:
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;
}
How i can make it?
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 06:16 PM   #6
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,193
Reputation: 420
Default Re: CMD content save. +REP

Quote:
Originally Posted by Osamakurdi View Post
This is code:
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.");
.....
	.........
}
How i can make it?
Uhm... your code already checks everything
__________________
Quote:
Originally Posted by Andy
My anti cheat is still relevant *puts shades on* https://github.com/RogueDrifter/Anti_cheat_pack

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link

RogueDrifter is offline   Reply With Quote
Old 03/01/2018, 06:16 PM   #7
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,506
Reputation: 305
Default Re: CMD content save. +REP

Ah no mane, this section is not for requesting code but for help in your written code You should learn the basics first before...
Logic_ is offline   Reply With Quote
Old 03/01/2018, 06:19 PM   #8
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: CMD content save. +REP

Quote:
Originally Posted by RogueDrifter View Post
Uhm... your code already checks everything
Yeah i've spent lifetime try to learn scripting

Now ik a bit
I created this cmd but,,
Its don't. Check money of acceptdice its same of money of dice.
+REP to all
Osamakurdi is offline   Reply With Quote
Old 03/01/2018, 06:23 PM   #9
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: CMD content save. +REP

Quote:
Originally Posted by Logic_ View Post
Ah no mane, this section is not for requesting code but for help in your written code You should learn the basics first before...
Im not requesting a code I already posted my code
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
[save error] my backpack save system Donggyu Scripting Help 0 09/06/2016 05:39 PM
Save/Loadcar and Save/load name color Acerbis Scripting Help 1 29/06/2014 03:29 PM
How do i add save kills and save deaths to my admin script? HayZatic Help Archive 2 09/07/2011 11:13 PM
guys i need help how to save money in this script i created a file but it wont save Artix Help Archive 5 30/05/2011 09:03 PM
I Made a save command that AddStaticVehicle saves. But how to save the colors? RyDeR` Help Archive 2 04/08/2009 09:20 PM


All times are GMT. The time now is 10:43 PM.


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