[Include] Basic Team
#1

Basic Team Include
Hello, kitten here i'm releasing a include that makes player making deathmatch/team deathmatch scripts much easier this include has the simple/basic functions of setting player team, getting player team, team chat, and many more you can do while just including the basicteam include you can use the basic team include in filterscripts/admin scripts/gamemodes which makes functions much more easier to use for teams.

Functions:

Код:
native GetScriptVersion(playerid);
native ClearChat(playerid);
native BTConnect(playerid);
native BTDisconnect(playerid);
native BTSpawn(playerid);
native GetTeamName(playerid);
native TeamChat(text[],playerid);
native SendCustomDeathMessage(killerid,playerid);
Teams (note: you don't have to use all the teams and you can always rename the team names via the include)
pawn Код:
#define TEAM_1 0
#define TEAM_2 1
#define TEAM_3 2
#define TEAM_4 3
#define TEAM_5 4
#define TEAM_INVALID 5
#define TEAM_SPEC 6

Example Script:

pawn Код:
#include <a_samp>
#include <BasicTeam>
#include <zcmd>

main()
{
}

public OnGameModeInit()
{
    SetGameModeText("BT Test Script");
    AddPlayerClass(0, 0.0,0.0,0.0,0.0,0,0,0,0,0,0); // team invalid
    AddPlayerClass(1, 0.0,0.0,0.0,0.0,0,0,0,0,0,0); // team 1
    AddPlayerClass(2, 0.0,0.0,0.0,0.0,0,0,0,0,0,0); // team 2
    AddPlayerClass(3, 0.0,0.0,0.0,0.0,0,0,0,0,0,0); // team 3
    AddPlayerClass(4, 0.0,0.0,0.0,0.0,0,0,0,0,0,0); // team 4
    AddPlayerClass(5, 0.0,0.0,0.0,0.0,0,0,0,0,0,0); // team 5
    AddPlayerClass(7, 0.0,0.0,0.0,0.0,0,0,0,0,0,0); // team spec
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 2924.9727,-1563.8043,11.0469);
    SetPlayerFacingAngle(playerid,86.8798);
    SetPlayerCameraPos(playerid, 2920.7109,-1563.5922,12.0877);
    SetPlayerCameraLookAt(playerid, 2924.9727,-1563.8043,11.0469);
   
    switch(classid) // Note not all the teams need to be used and you can rename the team name via the include.
    {
        case 0: { gTeam[playerid] = TEAM_INVALID, GameTextForPlayer(playerid,"Team Invalid",4000,4); }
        case 1: { gTeam[playerid] = TEAM_1, GameTextForPlayer(playerid,"Team 1",4000,4); }
        case 2: { gTeam[playerid] = TEAM_2, GameTextForPlayer(playerid,"Team 2",4000,4); }
        case 3: { gTeam[playerid] = TEAM_3, GameTextForPlayer(playerid,"Team 3",4000,4); }
        case 4: { gTeam[playerid] = TEAM_4, GameTextForPlayer(playerid,"Team 4",4000,4); }
        case 5: { gTeam[playerid] = TEAM_5, GameTextForPlayer(playerid,"Team 5",4000,4); }
        case 6: { gTeam[playerid] = TEAM_SPEC, GameTextForPlayer(playerid,"Team Spec",4000,4); }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    BTConnect(playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    BTDisconnect(playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    BTSpawn(playerid);
    SendClientMessage(playerid,-1,"use"COL_RED" !"COL_WHITE" to team chat");
    if(gTeam[playerid] == TEAM_1) return GivePlayerWeapon(playerid,24,100);
    if(gTeam[playerid] == TEAM_2) return GivePlayerWeapon(playerid,25,100);
    if(gTeam[playerid] == TEAM_3) return GivePlayerWeapon(playerid,30,100);
    if(gTeam[playerid] == TEAM_4) return GivePlayerWeapon(playerid,31,100);
    if(gTeam[playerid] == TEAM_5) return GivePlayerWeapon(playerid,27,100);
   
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SendCustomDeathMessage(killerid,playerid);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    TeamChat(text,playerid);
    return 0;
}

CMD:version(playerid) return GetScriptVersion(playerid);
CMD:myteam(playerid) return GetTeamName(playerid);

CMD:lost(playerid)
{
    if(gTeam[playerid] == TEAM_5)
    {
        SetPlayerPos(playerid,0.0,0.0,0.0);
        GameTextForPlayer(playerid,"~r~ LOST HAHA",6000,1);
    }
    else
    {
        SendClientMessage(playerid,-1,"["ScriptVersion"]"COL_WHITE" You must be in team 5 to use this command");
    }
    return 1;
}
Reminder to rename the ServerName to yours in the include.

Download:

http://zombie-mod.com/downloads/BasicTeam.inc
Reply
#2

Something tells me you made this for me 0_o Bai Bai.
Reply
#3

I find this utterly pointless lol? Just make a variable and reset it on OnPlayerDisconnect

pawn Код:
stock BTSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_INVALID)
    {
        SetPlayerHealth(playerid,0);
        ForceClassSelection(playerid);
        GameTextForPlayer(playerid,"~w~Please select an team",3000,4);
    }

    if(gTeam[playerid] == TEAM_SPEC)
    {
        new specrandom = random(MAX_PLAYERS);
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid,specrandom);
        return 1;
    }
    return 1;
}
You'd probably already know what's wrong with that code (especially the TEAM_SPEC)

HOOK YOUR CALLBACKS
Reply
#4

Why don't you use the definition "NO_TEAM" as invalid player team?
Reply
#5

Simple , but nice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)