SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 08/10/2013, 07:38 AM   #1
qazwsx
Huge Clucker
 
qazwsx's Avatar
 
Join Date: Jun 2013
Location: Semarang,Indonesia
Posts: 414
Reputation: 55
Default Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

============================
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 knowledge
2.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;
}

Here i had army class which spawned on Militarry ship on San Fierro:
pawn Code:
AddPlayerClass(287,-1318.9600,495.7722,18.2344,268.8795,0,0,0,0,0,0);

And that another one is SWAT skin spawned on SFPD Office
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];
You might get this warning when you hit compile:
pawn Code:
Symbol that is never used, pTeam
Dont worry, it will be fixed soon!

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;
}

Lil explanation:
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);
}
}

Okay lil explanation:
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;
}

issuerid is stands for attacker id, that just attacked someone. If he attacked teammate, he will get warning, by gametext.



Okay we've done here. I hope this tutorial helped
__________________
Ive left SAMP Scripting. I wont keep the update of my gamemodes. I might come back someday later, but didnt think about to come back to scripting ATM. However, I'd always come around to forums, chcking stuffs happened, and responds to thoose who have give their feedback on my gamemode.

-Regard
qazwsx
qazwsx is offline   Reply With Quote
Old 08/10/2013, 01:31 PM   #2
dusk
High-roller
 
dusk's Avatar
 
Join Date: Jul 2008
Posts: 1,114
Reputation: 46
Default Re: Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

Why use a variable for teams? You could just use natives: GetPlayerTeam / SetPlayerTeam
dusk is offline   Reply With Quote
Old 08/10/2013, 02:58 PM   #3
qazwsx
Huge Clucker
 
qazwsx's Avatar
 
Join Date: Jun 2013
Location: Semarang,Indonesia
Posts: 414
Reputation: 55
Default Re: Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

Quote:
Originally Posted by dusk View Post
Why use a variable for teams? You could just use natives: GetPlayerTeam / SetPlayerTeam
To make it a bit easily
__________________
Ive left SAMP Scripting. I wont keep the update of my gamemodes. I might come back someday later, but didnt think about to come back to scripting ATM. However, I'd always come around to forums, chcking stuffs happened, and responds to thoose who have give their feedback on my gamemode.

-Regard
qazwsx
qazwsx is offline   Reply With Quote
Old 09/10/2013, 03:17 PM   #4
qazwsx
Huge Clucker
 
qazwsx's Avatar
 
Join Date: Jun 2013
Location: Semarang,Indonesia
Posts: 414
Reputation: 55
Default Re: Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

No More comments?
__________________
Ive left SAMP Scripting. I wont keep the update of my gamemodes. I might come back someday later, but didnt think about to come back to scripting ATM. However, I'd always come around to forums, chcking stuffs happened, and responds to thoose who have give their feedback on my gamemode.

-Regard
qazwsx
qazwsx is offline   Reply With Quote
Old 10/10/2013, 08:40 AM   #5
Nofear192
Guest
 
Posts: n/a
Default Re: Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

Nice tutorial

+REP
  Reply With Quote
Old 14/10/2013, 05:09 AM   #6
PinkFloydLover
Gangsta
 
Join Date: Dec 2007
Location: Yes
Posts: 679
Reputation: 12
Default Re: Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

What dusk said,

SetPlayerTeam will automatically disable team killing, I would only use variables if I wanted friendly fire turned off.
PinkFloydLover is offline   Reply With Quote
Old 14/10/2013, 07:30 AM   #7
DanishHaq
High-roller
 
Join Date: Sep 2011
Location: Manchester, England, United Kingdom
Posts: 1,378
Reputation: 134
Default Re: Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

pawn Code:
PlayerPlaySound(issuerid,1057,0,0,0);//Playing a sound for attacker, that he has damaged someone

Is this the beeping noise or what noise is it? And the tutorial is ok.
DanishHaq is offline   Reply With Quote
Old 14/10/2013, 08:13 AM   #8
qazwsx
Huge Clucker
 
qazwsx's Avatar
 
Join Date: Jun 2013
Location: Semarang,Indonesia
Posts: 414
Reputation: 55
Default Re: Getting Started on TDM Scripting for newbie (Setting up team, Setting up team color, Anti teamkill[EXPLAINED]

Quote:
Originally Posted by DanishHaq View Post
pawn Code:
PlayerPlaySound(issuerid,1057,0,0,0);//Playing a sound for attacker, that he has damaged someone

Is this the beeping noise or what noise is it? And the tutorial is ok.
Well, it would like to play the "ding dong" sound when you hit someone
__________________
Ive left SAMP Scripting. I wont keep the update of my gamemodes. I might come back someday later, but didnt think about to come back to scripting ATM. However, I'd always come around to forums, chcking stuffs happened, and responds to thoose who have give their feedback on my gamemode.

-Regard
qazwsx
qazwsx 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
Setting a car for just one team not working. Magic_Time Scripting Help 1 30/07/2013 11:24 PM
Setting Default Team anonymousx Help Archive 4 19/02/2011 04:02 AM
Setting team matdav Help Archive 2 06/07/2010 07:26 PM
Setting player to team from skinid Gould Help Archive 2 04/08/2009 02:58 PM
setting score for team HELP PLEASE? Drift_04 Help Archive 1 27/02/2009 07:29 AM


All times are GMT. The time now is 03:20 AM.


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