08.10.2013, 06:38
============================
INTRODUCTION
============================
Hello guys, im back with new tutorial. This tutorial explaining about how to getting started on TDM Scripting for you guys that have just getting started and want to make simple TDM. So why wasting time. lets start!REQUIRETMENTS
1.Pawno basic scripting knowledge2.Brain
Working
1.Setting Up Our team by class!Okay so the first step we are going on do here is setting up our team depends by classes. Take it, we had army class skin, so we want to set it as army team, etc.
First, we are going to add our classes. We gotta put it on call back function OnGameModeInit
pawn Code:
public OnGameModeInit()
{
AddPlayerClass(287,-1318.9600,495.7722,18.2344,268.8795,0,0,0,0,0,0);
AddPlayerClass(285,-1615.5643,683.4233,7.1875,176.2447,0,0,0,0,0,0);
return 1;
}
pawn Code:
AddPlayerClass(287,-1318.9600,495.7722,18.2344,268.8795,0,0,0,0,0,0);
We have just added our classes!Now time to setting up the team!
Before to setting up team, we are going to create a variable which stands for handle player team
In the top of your script add this:
pawn Code:
new pTeam[MAX_PLAYERS];
pawn Code:
Symbol that is never used, pTeam
And dont forget to define the team:
pawn Code:
#define ARMY 0
#define COP 1
And now time to setting up your team.
Add this:
pawn Code:
public OnPlayerRequestClass(playerid,classid)
{
if(classid == 0)
{
pTeam[playerid] = ARMY;
}
if(classid == 1)
{
pTeam[playerid] = COP;
}
return 1;
}
Generally, when we are connected there will be classes to shown. If we switch to first class, we setted the team to ARMY. While, if switch for next class /second class,we setted the team to COP
And ofc, we dont want everyone kill each other. Therefore, we gotta set player color depends on their team. Add this:
pawn Code:
public OnPlayerSpawn(playerid)
{
if(pTeam[playerid] == ARMY)
{
SetPlayerColour(playerid,COLOR_GREY);//Change the color, as color you have defined Before
}
if(pTeam[playerid] == COPS)
{
SetPlayerColour(playerid,COLOR_BLUE);//Change the color, as color you have defined
GivePlayerWeapon(playerid,31,200);
}
}
If player select Army skin on class selection, once they spawned, their color will be turned to Grey. Otherwise, if they selected SWAT skin on class selection, once they spawned, their color will be turned to blue. And, they will be given a M4 Per spawned.Of course you can change it as you want.
Okay we have done here, and we setted UP OUR TEAM!
Now, we want make simple anti teamkill! So, when they attacked their teammate, they will get warnings to not do teamkill.
Add this:
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(pTeam[issuerid] == pTeam[playerid])
{
new Float:health,Float:Armour;
GetPlayerHealth(playerid,health);//get the player health
GetPlayerArmour(playerid,Armour);//get player amour
SetPlayerHealth(playerid,health);/set their health to default health
SetPlayerArmour(playerid,Armour);//set their armour to default armour
GameTextForPlayer(issuerid,"Watch your shoot!",2000,5);//give a warning to attacker, that he attacked teammate
}
else
{
PlayerPlaySound(issuerid,1057,0,0,0);//Playing a sound for attacker, that he has damaged someone
}
return 1;
}
Okay we've done here. I hope this tutorial helped