[Tool/Web/Other] Orel Reshka :)
#1

Hi guys,i worked on pawno and decided create my Mode ).
I created first system "Orel and Reshka(Russian)"
Basically, the system needs to check the player's luck and make some money)

Go.

Defines:
Code:
#define prizedollars 500//Prize $
#define costor 500//Command Cost
#define OREL_RESHKA_DL 123//Dialog
#define OREL_RESHKA_DL_1 1231//Dialog 1_1
#define OREL_RESHKA_DL_2 1232//Dialog 1_2
New:
Code:
new lucky[MAX_PLAYERS];
new choose[MAX_PLAYERS];
OnPlayerCommand:
Code:
	if(strcmp(cmd, "/lucky", true) == 0) {
		if(GetPlayerMoney(playerid) < costor){
			new str[128];
			format(str,sizeof(str),"You don`t have %d dollars!",costor);
			SendClientMessage(playerid,-1,str);
			return 1;}
		else{
			GivePlayerMoney(playerid,costor);
			ShowPlayerDialog(playerid,OREL_RESHKA_DL,DIALOG_STYLE_MSGBOX,"Orel Reshka","Choose:","Orel","Reshka");
			return 1;}
	}
OnDialogResponse:
Code:
if(dialogid == OREL_RESHKA_DL)
	{
		new str[256];
		if(response)
		{
				choose[playerid] = 1;
				new rand = random(7);
				new stringer[10];
				switch(rand)
				{
					case 0:lucky[playerid] = 1,stringer = "Orel";
					case 1:lucky[playerid] = 2,stringer = "Reshka";
					case 2:lucky[playerid] = 2,stringer = "Reshka";
					case 3:lucky[playerid] = 2,stringer = "Reshka";
					case 4:lucky[playerid] = 2,stringer = "Reshka";
					case 5:lucky[playerid] = 2,stringer = "Reshka";
					case 6:lucky[playerid] = 1,stringer = "Orel";
				}
				new str1[64];
				format(str1,sizeof(str1),"%s",stringer);
				if(lucky[playerid] == choose[playerid]){
					format(str,sizeof(str),"Answer: %s\nCongratulations, you guessed it!",str1);
					ShowPlayerDialog(playerid,OREL_RESHKA_DL_1,DIALOG_STYLE_MSGBOX,"Orel Reshka",str,"Thank","");
				}
				else if(lucky[playerid] != choose[playerid]){
					format(str,sizeof(str),"Answer: %s\nSorry you are wrong!",str1);
					ShowPlayerDialog(playerid,OREL_RESHKA_DL_2,DIALOG_STYLE_MSGBOX,"Orel Reshka",str,"Falied","");
				}
		}
		else
			{
				choose[playerid] = 2;
				new rand = random(7);
				new stringer[10];
				switch(rand)
				{
					case 0:lucky[playerid] = 1,stringer = "Orel";
					case 1:lucky[playerid] = 1,stringer = "Orel";
					case 2:lucky[playerid] = 2,stringer = "Reshka";
					case 3:lucky[playerid] = 2,stringer = "Reshka";
					case 4:lucky[playerid] = 1,stringer = "Orel";
					case 5:lucky[playerid] = 1,stringer = "Orel";
					case 6:lucky[playerid] = 1,stringer = "Orel";
				}
				new str1[64];
				format(str1,sizeof(str1),"%s",stringer);
				if(lucky[playerid] == choose[playerid]){
					format(str,sizeof(str),"Answer: %s\nCongratulations, you guessed it!",str1);
					ShowPlayerDialog(playerid,OREL_RESHKA_DL_1,DIALOG_STYLE_MSGBOX,"Orel Reshka",str,"Thank","");
				}
				else if(lucky[playerid] != choose[playerid]){
					format(str,sizeof(str),"Answer: %s\nSorry you are wrong!",str1);
					ShowPlayerDialog(playerid,OREL_RESHKA_DL_2,DIALOG_STYLE_MSGBOX,"Orel Reshka",str,"Falied","");
				}
			}
	}
	if(dialogid == OREL_RESHKA_DL_1){
		new money = prizedollars;//Prize
		GivePlayerMoney(playerid,money);
		SendClientMessage(playerid,-1,"You can also test your luck again!:)");
		return 1;
	}
	if(dialogid == OREL_RESHKA_DL_2){
		SendClientMessage(playerid,-1,"Do not worry, you can be lucky next time!:(");
		return 1;
	}
P.S I used standart command processor
Good Luck!
Reply
#2

Hello OP, it's cool you shared what you've learned, I have a few issues though:
1. Please for the love of God, use indentation properly
2. You gave player money even before the flip was made, that's not a good casino rule...
3. This casino cheats as hell: if I bet I have only 29% chance of winning? HEY!
Reply
#3

This isn't a tutorial! You explained nothing, and just gave us code. You cannot do that in this section - either change it to a tutorial form or request a thread move to an appropriate section(such as the filterscript / release section).

You also have some bad scripting habits going on, for example the switch.

pawn Code:
switch(rand)
                {
                    case 0:lucky[playerid] = 1,stringer = "Orel";
                    case 1:lucky[playerid] = 2,stringer = "Reshka";
                    case 2:lucky[playerid] = 2,stringer = "Reshka";
                    case 3:lucky[playerid] = 2,stringer = "Reshka";
                    case 4:lucky[playerid] = 2,stringer = "Reshka";
                    case 5:lucky[playerid] = 2,stringer = "Reshka";
                    case 6:lucky[playerid] = 1,stringer = "Orel";
                }
Now basically instead of using 2 lines you spread it over 7 - when the results are purely the same. A better code would be:

pawn Code:
switch(rand)
                {
                    case 0,6:lucky[playerid] = 1,stringer = "Orel";
                    case 1..5:lucky[playerid] = 2,stringer = "Reshka";
                                        default: return 0; // This shouldn't be called but just in case let's have it return 0.
                }
Reply
#4

Quote:
Originally Posted by Misiur
View Post
Hello OP, it's cool you shared what you've learned, I have a few issues though:
1. Please for the love of God, use indentation properly
2. You gave player money even before the flip was made, that's not a good casino rule...
3. This casino cheats as hell: if I bet I have only 29% chance of winning? HEY!
And how should it be?
Reply
#5

Quote:
Originally Posted by Misiur
View Post
Hello OP, it's cool you shared what you've learned, I have a few issues though:
1. Please for the love of God, use indentation properly
2. You gave player money even before the flip was made, that's not a good casino rule...
3. This casino cheats as hell: if I bet I have only 29% chance of winning? HEY!
Quote:
Originally Posted by Abagail
View Post
This isn't a tutorial! You explained nothing, and just gave us code. You cannot do that in this section - either change it to a tutorial form or request a thread move to an appropriate section(such as the filterscript / release section).

You also have some bad scripting habits going on, for example the switch.

pawn Code:
switch(rand)
                {
                    case 0:lucky[playerid] = 1,stringer = "Orel";
                    case 1:lucky[playerid] = 2,stringer = "Reshka";
                    case 2:lucky[playerid] = 2,stringer = "Reshka";
                    case 3:lucky[playerid] = 2,stringer = "Reshka";
                    case 4:lucky[playerid] = 2,stringer = "Reshka";
                    case 5:lucky[playerid] = 2,stringer = "Reshka";
                    case 6:lucky[playerid] = 1,stringer = "Orel";
                }
Now basically instead of using 2 lines you spread it over 7 - when the results are purely the same. A better code would be:

pawn Code:
switch(rand)
                {
                    case 0,6:lucky[playerid] = 1,stringer = "Orel";
                    case 1..5:lucky[playerid] = 2,stringer = "Reshka";
                                        default: return 0; // This shouldn't be called but just in case let's have it return 0.
                }
It`s my first system.
Of course there will be mistakes, not everything is perfect)
Reply
#6

First off, this is not a tutorial in any way, you haven't explained anything at all.
A tutorial means to explain what to do, why to do it, and how it works.

Second, why do you have the [Tool/Web/Other]-tag in the tutorial section?
Reply
#7

Quote:
Originally Posted by SnoopDy
View Post
It`s my first system.
Of course there will be mistakes, not everything is perfect)
but when it comes to coding, everything SHOULD and MUST be perfect
Reply
#8

This ready-made solution )

As I can and I bring the script to perfection, this version I have overthrown yesterday, today I did timers, animation and added on the public, and not in dialog.Progress)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)