SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/06/2018, 08:15 PM   #1
ChampGamer
Little Clucker
 
Join Date: Dec 2017
Posts: 10
Reputation: 5
Exclamation Deathmatch Arena System || With Dialogs

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.

Last edited by ChampGamer; 11/06/2018 at 10:57 AM.
ChampGamer is offline   Reply With Quote
Old 12/06/2018, 12:18 AM   #2
Exhibit
Big Clucker
 
Join Date: Dec 2015
Location: Basement.
Posts: 165
Reputation: 19
Default Re: Deathmatch Arena System || With Dialogs

Don't release tutorials if you don't know what you are doing, You have a long way to go. Plus, use SetSpawnInfo.
__________________
rg-clan.eu | relentlessdm.com
Exhibit 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
[Map] DeathMatch - Arena Zeta_- Maps 10 23/07/2013 11:16 AM
[Map] Deathmatch Arena DJMickeyMouse Maps 5 25/06/2013 01:08 PM
[Map] DeathMatch - Arena 3.0 Rodrigo_FusioN Lanšamentos/Releases 13 04/11/2012 02:31 PM
[Map] [MAP]Deathmatch arena Roperr Maps 23 18/08/2012 12:08 PM


All times are GMT. The time now is 10:46 AM.


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