[Tutorial] Creating DeathMatch zone
#1

Introduction:
Hey guys, this is my first tutorial, So i will show gow to create DeathMatch zone, what u need is only zcmd include witch u can download here: CLICK this is not so and u need to know only basics of pawno..So lets get started

Getting Started:
fors what u need is to include zcmd and define color and dialog
pawn Код:
#include <zcmd> //include for commands
#define DM_ZONE 3000 //This is defining dialog id...
#define red  0xFF0000FF //and this is defining the color witch we will use it later
Step 2:
Now we will ad the forward wich will later Reset and Remove weapons from players when he join or exit from dm zone
pawn Код:
forward RemovePlayerWeapon(playerid, weaponid);
forward SafeResetPlayerWeapons(plyid);
Step 3:
Now that we have done now we need to add somthing at the enum, what you need to do is to find where is your enum for players andd add this:

pawn Код:
pTeam
Step 4:
now what we need to do is to add SetPlayerSpawn under OnPlayerSpawn that we need because when someone die in DM zone to spawn him again on spawn of him team, and we will define it later

pawn Код:
SetPlayerSpawn(playerid);//under OnPlayerSpawn
Step 5 Commands:
now we add commands for DM zone to players can join or exit DM zone

pawn Код:
CMD:dmenter(playerid, params[])
{
ShowPlayerDialog(playerid, DM_ZONE, DIALOG_STYLE_LIST, "Team Choose", "{CD3333}Red Team\n{009ACD}Blue team", "OK", "Exit");
return 1;
}
And this the dialog, this dialog is for when player pick the team if he choose red to set him red team and if he choose blue to set him in blue team so we will add this under OnPlayerDialogResponse
pawn Код:
if(dialogid == DM_ZONE)
        {
        if(response)
        {
            if(listitem == 0) //if pick team 1
            {
            GivePlayerWeapon(playerid, 24, 750);
            GivePlayerWeapon(playerid, 31, 500);
            GivePlayerWeapon(playerid, 29, 450);
            SetPlayerPos(playerid,1827.7347,-1408.3877,29.6172);//put cords of team 1
            SendClienMessage(playerid, red, "{FFFFFF}U entered in{CD3333}Red team ");//send player msg
            PlayerInfo[playerid][pTeam] = 1;
            }
            if(listitem == 1) //if pick team 2
            {
            GivePlayerWeapon(playerid, 24, 750);
            GivePlayerWeapon(playerid, 31, 500);
            GivePlayerWeapon(playerid, 29, 450);
            SetPlayerPos(playerid,1831.1451,-1415.4196,29.6172);//pur cords of team 2
            SendClienMessage(playerid, red, "{FFFFFF}U entered in{009ACD}Blue team");//Send player msg
            PlayerInfo[playerid][pTeam] = 2;

            }
        }
}
And this is the command if player wonna to exit from DM zone when he type:dmexit to remove him weapons and to set him pos out of DM zone

pawn Код:
CMD:dmexit(playerid, params[])
{
new gunID = GetPlayerWeapon(playerid);
PlayerInfo[playerid][pTeam] = 0;
SetPlayerPos(playerid,1765.5070,-1361.6622,15.8299);//Cords where to player spawn on exit from D; zone
RemovePlayerWeapon(playerid, gunID);
SendClientMessage(playerid, red, "{FFFFFF}U exit from{CD3333}DM Zone");
return 1;
}
Now we will add 2 more commands for chat. This command allow to teams can chat!
pawn Код:
CMD:redchat(playerid, params[])
{
        if (PlayerInfo[playerid][pTeam] == 1)
        {
               new mesa[128], string2[256];
   GetPlayerName(playerid, GetName(playerid), 20);
   if(sscanf(params, "s[128]", mesa)) return SCM(playerid, red,"{009ACD}COMMAND:{FFFFFF}/rechat {009ACD}[text]");
   format(string2, sizeof(string2), "{CD3333}[RED TEAM]{FFFFFF} %s {CD3333}Say: {FFFFFF}%s",GetName(playerid), poruka);
   SendRedMessage(red, string2);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, red, "{FFFFFF}({CD3333}EOOR{FFFFFF}):You are not in{CD3333}Red{FFFFFF}Team!");
        }
        return 1;
    }
pawn Код:
CMD:bluechat(playerid, params[])
{
        if (PlayerInfo[playerid][pTeam] == 2)
        {
               new mesa[128], string2[256];
   GetPlayerName(playerid, GetName(playerid), 20);
   if(sscanf(params, "s[128]", mesa)) return SCM(playerid, red,"{009ACD}COMMAND:{FFFFFF}/bluechat {009ACD}[text]");
   format(string2, sizeof(string2), "{009ACD}[Blue Team]{FFFFFF} %s {009ACD}Say: {FFFFFF}%s",GetName(playerid), poruka);
   SendBlueMessage(red, string2);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, red, "{FFFFFF}({CD3333}ERROR{FFFFFF}):You are not in {009ACD}Blue {FFFFFF}Team!");
        }
        return 1;
    }
Step 6 Some Defines:
Now this we will add when player die in DM zone to set him spawn in DM zone of him team...
Add this under OnPlayerDeath
pawn Код:
SetPlayerSpawn(playerid);
And this is the stocks, that is for chat, that is sending the message to teams when they chat, u can add it on the end of the scirpt..
pawn Код:
stock SendRedMessage(color, string[])
{
foreach (Player, i)
{
if(PlayerInfo[i][pTeam] == 1)
{
SendClientMessage(i, color, string);
}
}
}
pawn Код:
stock SendBlueMessage(color, string[])
{
foreach (Player, i)
{
if(PlayerInfo[i][pTeam] == 2)
{
SendClientMessage(i, color, string);
}
}
}
And this is stock to get player name add it where u added this previous stocks..
pawn Код:
stock GetName(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return pName;
}
And i said when we added SetPlayerSpawn under OnPlayerSpawn to we will defne it, you can add this on the end of the scirpt..
pawn Код:
forward SetPlayerSpawn(playerid);
public SetPlayerSpawn(playerid)
{
if(PlayerInfo[playerid][pTeam] == 1)
{
SetPlayerPos(playerid,1827.7347,-1408.3877,29.6172);//cords of red team spawn
GivePlayerWeapon(playerid, 24, 750);
GivePlayerWeapon(playerid, 31, 500);
GivePlayerWeapon(playerid, 29, 450);
}
if(PlayerInfo[playerid][pTeam] == 2)
{
SetPlayerPos(playerid,1831.1451,-1415.4196,29.6172);//cords of blue team spawn
GivePlayerWeapon(playerid, 24, 750);
GivePlayerWeapon(playerid, 31, 500);
GivePlayerWeapon(playerid, 29, 450);
}
return 1;
}
The End


if someone get errors post it here and i will see what i can do
Reply
#2

1- You better organize your thread use a better font not that big with not such bright colors

2- Use or to make it look better

so 5/10.
Reply
#3

Would be easier to read if you used the pawn tags.
Also, work on your indentation.
Reply
#4

Quote:
Originally Posted by Vedo_
Посмотреть сообщение
1- You better organize your thread use a better font not that big with not such bright colors

2- Use or to make it look better

so 5/10.
Ok thanks for instructions, i edited whoe text and this now look much better,THANKS
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)