[Tutorial] Deathmatch Arena System || With Dialogs
#1

Introduction
So this tutorial is based on a Deathmatch Arena system with dialogs. So Basically I am working on a deathmatch server on SA-MP 0.3DL and I thought it would be good if I release the arenas system for the newbie scripters( I am one myself ).

Tutorial
Step # 1:
So first of all we're gonna start with making a function to determine weather the player that uses the command is in an arena or not. So do the following :
Code:
new Arena1[MAX_PLAYERS];
And we have to define the dialog ID so do the following define :
Code:
#define DIALOG_ARENAS
Step # 2:
Second we're gonna set the player not in an arena when they connect and disconnect. So do the following:
Code:
public OnPlayerConnect
{
Arena1[playerid] = 0;
return 1;
}

public OnPlayerDisconnect
{
Arena1[playerid] = 0;
return 1;
}
Step # 3:
Now finally we're gonna set up a command that will show us the list of arenas that are available to play. I'm just gonna add a Ghost town arena as an example, you can add more by following the same code that'll tell you in this tutorial later on. So here's the code for the command, make sure you have ZCMD in order to do this without any errors.
Code:
CMD:arenas(playerid, params[])
{
ShowPlayerDialog(playerid, DIALOG_ARENAS, DIALOG_STYLE_LIST, " Areans ", "{FFCCFF}Ghost Town)", "Select", " Cancel ");
return 1;
}
Step # 4:
Now we're gonna set what's gonna happen when we select an option. For that we use OnDialogResponse Callback. Here's the code:
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_ARENAS:
        {
            if(response)
	     {
	             switch(listitem)
		     {
			    case 0:
			    {
				Arena1[playerid] = 1;
				SetPlayerHealth(playerid, 100);
				GivePlayerWeapon(playerid, 29, cellmax);
				GivePlayerWeapon(playerid, 16, 50);
				SetPlayerPos(playerid,-379.2165,2247.3938,42.6185);
					    
     				new str[200], name[MAX_PLAYER_NAME];
				GetPlayerName(playerid, name, sizeof(name));
				format(str, sizeof(str), "{FF33CC}ARENAS : {FFFFFF}%s has entered the Ghost Town.", name, playerid);
				SendClientMessageToAll(-1, str);
                            }
                      }
                 }
             }
        }
     return 1;
}
Step # 5:
Now we'll add a respawn system to make sure that player spawns in the arena when he dies, for that, we'll use on OnPlayerSpawn. Here's the code :
Code:
public OnPlayerSpawn(playerid)
{
    if(Arena1[playerid] == 1)
	{
		SetPlayerHealth(playerid, 100);
		GivePlayerWeapon(playerid, 24, cellmax);
		GivePlayerWeapon(playerid, 25, cellmax);
		SetPlayerInterior(playerid, 3);
		SetPlayerPos(playerid, 231.9844,172.3727,1003.0234);
         }
    return 1;
}
Thanks for reading this tutorial, it's my first tutorial so feel free to tell me my mistake and ask any questions about it below.
Reply


Messages In This Thread
Deathmatch Arena System || With Dialogs - by ChampGamer - 10.06.2018, 20:15
Re: Deathmatch Arena System || With Dialogs - by Exhibit - 12.06.2018, 00:18

Forum Jump:


Users browsing this thread: 1 Guest(s)