How to make DM minigame with respawns after death -
RuthlessThuG - 18.02.2013
Introduction
Hello everyone I have seen many tutorials on how to make DM most of them were simple
so I decided to make my tutorial
In this tutorial you will learn how to make DM and after you die you will respawn at DM
If you asking "What is DM ?" DM is a Deathmatch between every player
Most Freeroam stunt servers using this mini game
OK let's start
You will only need
I will use lightblue color,
you can use anycolor you want ...
pawn Код:
#define COLOR_LIGHTBLUE 0x33CCFF19//define for lightblue
Under it add
pawn Код:
new String[256]; // String for messages
new InDM[MAX_PLAYERS]; // We will use it later to tell the script if the player is in DM or not
now we will make random spawns
pawn Код:
new Float:DMSpawns[][4] = { // Random spawns so players won't spawn at the same place
{609.7040,-586.5684,17.2266,256.8267},
{610.3588,-590.8182,17.2266,263.0453},
{616.1186,-591.2390,17.2330,268.1367}
//I will be using 3 you can add more if you want
};
Now when the player connect we will set him as not in DM
so he wont get bugged
pawn Код:
public OnPlayerConnect(playerid)
{
InDM[playerid] = 0; // This will set the player as not in DM
return 1;
}
also when the player disconnect
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
InDM[playerid] = 0; // Makes the player set as not in the DM
return 1;
}
Now we will make respawn's after death when player is in DM
Under public OnPlayerSpawn(playerid)
add
pawn Код:
public OnPlayerSpawn(playerid)
{
if(InDM[playerid] == 1)//This will tell the script to respawn only the players that inside DM
{
SetPlayerInterior(playerid, 0); // We will set the interior to 0 (you can change it to your own DM)
SetPlayerVirtualWorld(playerid, 10); // and we will make the Virtual World in different world, so we wont mix with other players
new rand = random(sizeof(DMSpawns)); // DM Spawn
SetPlayerPos(playerid, DMSpawns[rand][0], DMSpawns[rand][1], DMSpawns[rand][2]);// we will set the player position at DM
SetPlayerFacingAngle(playerid, DMSpawns[rand][3]); // Also facing Angle
//and we will give him weapons, I will give 2 weapons
GivePlayerWeapon(playerid, 24, 1500); // Desert Eagle
GivePlayerWeapon(playerid, 26, 1500); // Sawnoff Shutgun
//you can edit them, or add more weapons
}
return 1;
}
SetPlayerInterior
SetPlayerVirtualWorld
GivePlayerWeapon
Weapons ID
OK lets continue
now we will make the commands to exit/join DM
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/dm", cmdtext, true, 4) == 0) //(/dm) command
{
new PlayerName[MAX_PLAYER_NAME];//Player name
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(InDM[playerid] == 0)//if the player is not in DM
{//then
InDM[playerid] = 1; // Now we will set him in DM so he will respawn at DM
SendClientMessage(playerid, COLOR_LIGHTBLUE , "You have joined /dm, to leave type /dm again");//Message to tell him that he joined DM
format(String, sizeof(String), "Server:{FFFFFF}%s(%d) has joined DM(/dm)", PlayerName, playerid);
SendClientMessageToAll(COLOR_LIGHTBLUE, String);//Message to tell everyone that he joined DM
SetPlayerInterior(playerid, 0); // Just like we did before we will set he's interior to 0
SetPlayerVirtualWorld(playerid, 10); // and same here Virtual World to 10
new rand = random(sizeof(DMSpawns)); // DM Spawn
SetPlayerPos(playerid, DMSpawns[rand][0], DMSpawns[rand][1], DMSpawns[rand][2]);// we will set the player position at DM
SetPlayerFacingAngle(playerid, DMSpawns[rand][3]); // Also facing Angle
//and we will give him weapons, I will give 2 weapons
GivePlayerWeapon(playerid, 24, 1500); // Desert Eagle
GivePlayerWeapon(playerid, 26, 1500); // Sawnoff Shutgun
//you can edit them, or add more weapons if you want
}
else {//if the player is already in DM, he will leave
InDM[playerid] = 0; //So now we will set him as not in DM
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have left /dm to join again type /dm");//We will send him a message to tell him that he left
SpawnPlayer(playerid);//We will spawn the player now
SetPlayerHealth(playerid, 100);//set he's health to 100
ResetPlayerWeapons(playerid);// and reset he's weapons
SetPlayerVirtualWorld(playerid, 0);//we will set he's virtual world to 0
SetPlayerInterior(playerid, 0);//also interior to 0
}
return 1;
}
return 0;
}
that's it ...
also a small Tip:
as you in DM you want to disable other commands
here is how to do it
For example I will do it on (/kill) command as everyone know this command
pawn Код:
if (strcmp("/kill", cmdtext, true, 4) == 0) // Kill command
{
SetPlayerHealth(playerid, 0);//we will set he's health to 0
}
return 0;
add
pawn Код:
if(InDM[playerid] == 0) //to tell if the player is in DM or not
on top of your command
like this
pawn Код:
if (strcmp("/kill", cmdtext, true, 4) == 0) // Kill command
{
if(InDM[playerid] == 0)//if the player is not in DM
{//then
SetPlayerHealth(playerid, 0);//we will set he's health to 0
}//if he's in DM
else return SendClientMessage(playerid, COLOR_RED, "You cannot use this command in DM minigame !");//we will send him a message that he cannot use this command in DM
}
return 0;
}
hope I helped
please don't complaint if this tutorial is not good
as it my first tutorial
I want to thank Dr.Papper
I learned this from he's work
if there any bug please tell me
Thanks !
Re: How to make Deathmatch with respawns after death -
faiznurfaza - 19.02.2013
How to create random spawn if not in dm minigame? Yo dawg, DM IN DM :v
Re: How to make Deathmatch with respawns after death -
RuthlessThuG - 19.02.2013
If you are not DM you wont respawn at DM
If you are in DM you will respaw at DM
to make random spawns for player
first make the random spawn
pawn Код:
new Float:RandomSpawns[][4] = { // Random spawns for player that not in DM
{609.7040,-586.5684,17.2266,256.8267},
{610.3588,-590.8182,17.2266,263.0453},
{616.1186,-591.2390,17.2330,268.1367}//I will use same position's just to show you how yo make it
//I will be using 3 you can add more if you want
};
now if you want to add random spawn + DM spawn
do it like this
pawn Код:
public OnPlayerSpawn(playerid)
{
if(InDM[playerid] == 1)//This will tell the script to respawn only the players that inside DM
{
SetPlayerInterior(playerid, 0); // We will set the interior to 0 (you can change it to your own DM)
SetPlayerVirtualWorld(playerid, 10); // and we will make the Virtual World in different world, so we wont mix with other players
new rand = random(sizeof(DMSpawns)); // DM Spawn
SetPlayerPos(playerid, DMSpawns[rand][0], DMSpawns[rand][1], DMSpawns[rand][2]);// we will set the player position at DM
SetPlayerFacingAngle(playerid, DMSpawns[rand][3]); // Also facing Angle
//and we will give him weapons, I will give 2 weapons
GivePlayerWeapon(playerid, 24, 1500); // Desert Eagle
GivePlayerWeapon(playerid, 26, 1500); // Sawnoff Shutgun
//you can edit them, or add more weapons
}
else {
new rand = random(sizeof(RandomSpawns)); // Ramdom Spawns
SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);// we will set the player position (Random spawns
SetPlayerFacingAngle(playerid, RandomSpawns[rand][3]); // Also facing Angle
}
return 1;
}
if you don't want the DM spawns and you want only the Random spawn do it like this
pawn Код:
public OnPlayerSpawn(playerid)
{
new rand = random(sizeof(RandomSpawns)); // Random Spawn
SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);// we will set the player position (random spawns)
SetPlayerFacingAngle(playerid, RandomSpawns[rand][3]); // Also facing Angle
return 1;
}
It's very simple
Hope you understand
Re: How to make Deathmatch with respawns after death -
nhunor58 - 19.02.2013
really nice helped me a lot

)
Re: How to make Deathmatch with respawns after death -
RuthlessThuG - 20.02.2013
I'm glad to help you
Re: How to make Deathmatch with respawns after death -
The.Game - 20.02.2013
Very good tutorial
Re: How to make Deathmatch with respawns after death -
IC - 07.03.2013
very good tutorial
Great job
Re: How to make Deathmatch with respawns after death -
сомрτоn - 17.03.2013
Nice tutorial
Good job
Re: How to make Deathmatch with respawns after death -
Konstantinos - 17.03.2013
Nice tutorial, but please change
to
The limit for client messages are 128 chars and it's waste of memory to use 256!
Re: How to make Deathmatch with respawns after death -
nhunor58 - 24.03.2013
If I use it as a Filterscript i don't respawn in Dm!!WHY?
Re: How to make Deathmatch with respawns after death -
UnitedChaos - 08.11.2013
how to make player type /exit to quit /dm
Pls Help
Re: How to make Deathmatch with respawns after death -
Gafsi - 30.11.2013
Really good job u helped me alot thank you sir =)
Re: How to make Deathmatch with respawns after death -
newbie scripter - 01.12.2013
Quote:
Originally Posted by UnitedChaos
how to make player type /exit to quit /dm
Pls Help 
|
Simple
pawn Код:
// ur random spawn cmd.
i will use ZCMD so:
CMD:exit(playerid, params[])
{
if(InDM[playerid] == 1)
{
new rand = random(sizeof (/* ur randspawn name */))
SetPlayerPos(playerod, /*randspawn name*/[rand] [0],/*randspawn name*/[rand] [1],/*randspawn name*/[rand] [2]);
InDM[playerid] = 0;
}
else return SendClientMessage(playerid, -1, "You need to be in DM to use this command");
}