[HELP] Adding teams/team colors and text
#1

Hi!
So I am completely fresh within scripting, and I've been reading guides and watching tutorials and thought I would get it working. (Yes I realize that when I used the search function there are tons of guides on this with teams and team colors, and I've read many).

I am not getting any error messages, however it just won't work.
I am trying to learn, so if you know what I'm doing wrong, let me know.

1) I'm really not sure if the teams work, as I don't know how to test that when I'm alone and testing in lanmode.
2) Team colors I don't think work because when I type something in the chat, the color is always orange, and I would have guessed that the color would change to their team color.
3) And last but not least, at the class selection screen, I'd like it to say "Grove" in green over the 3 grove classes, "Vagos" over the 3 vago classes, and "Ballas" over the 3 balla classes.


Thanks

Pastebin link if you prefer:
http://pastebin.com/39wVP4rD

Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#define TEAM_GROVE 1
#define TEAM_BALLA 2
#define TEAM_VAGO 3
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple
#define TEAM_VAGO_COLOR 0xFFFF00AA // Bright Yellow
#define TEAM_VAGO_COLOR 0xFFFF00AA // Bright Yellow

// Colors
#define COLOR_RED 0xAA3333AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_SPAWN 0xFF8C55FF
#define COLOR_LIGHTBLUE 0x6DC5F3FF
#define COLOR_ADMIN 0xFF0000FF
#define COLOR_SAY 0x2986CEFF
#define COLOR_SYSGREY 0xC6BEBDFF
#define COLOR_BLACK 0x000000FF
#define COLOR_JOIN 0x74E80099
#define COLOR_WARN 0xBE615099
#define COLOR_RACE 0x00BBBB99
#define COLOR_KRED 0xFF0000FF

new gTeam[MAX_PLAYERS];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by Your Name");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by Your Name");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    SetGameModeText("Pro gamemode");
    
    // Player Classes
    AddPlayerClass(102,2004.5212,-1183.4020,20.0234,325.7480,24,1500,27,1500,16,2); // Glen Park Ballas spawn
    AddPlayerClass(103,2004.5212,-1183.4020,20.0234,325.7480,24,1500,27,1500,16,2); // Glen Park Ballas spawn
    AddPlayerClass(104,2004.5212,-1183.4020,20.0234,325.7480,24,1500,27,1500,16,2); // Glen Park Ballas spawn
    AddPlayerClass(105,2224.2893,-1337.3351,23.9825,81.0793,24,1500,27,1500,16,2); // LS Church Grove Street spawn
    AddPlayerClass(106,2224.2893,-1337.3351,23.9825,81.0793,24,1500,27,1500,16,2); // LS Church Grove Street spawn
    AddPlayerClass(107,2224.2893,-1337.3351,23.9825,81.0793,24,1500,27,1500,16,2); // LS Church Grove Street spawn
    AddPlayerClass(108,2215.1963,-1164.0492,25.7266,270.5322,24,1500,27,1500,16,2); // Jefferson Vagos spawn
    AddPlayerClass(109,2215.1963,-1164.0492,25.7266,270.5322,24,1500,27,1500,16,2); // Jefferson Vagos spawn
    AddPlayerClass(110,2215.1963,-1164.0492,25.7266,270.5322,24,1500,27,1500,16,2); // Jefferson Vagos spawn

    // Vehicles
    AddStaticVehicle(410,2017.9709,-1130.4572,24.6213,90.8939,149,149); // Glen Park Ballas car 1
    AddStaticVehicle(410,2006.1056,-1130.5358,24.9586,89.6824,149,149); // Glen Park Ballas car 2
    AddStaticVehicle(410,1994.2158,-1130.3481,25.2871,88.4700,149,149); // Glen Park Ballas car 3
    AddStaticVehicle(410,1981.5905,-1130.3733,25.5798,89.6619,149,149); // Glen Park Ballas car 4
    AddStaticVehicle(410,1981.2972,-1141.2786,25.5761,268.5168,149,149); // Glen Park Ballas car 5
    AddStaticVehicle(421,1990.6437,-1141.3054,25.3712,269.7369,149,149); // Glen Park Ballas car 6
    AddStaticVehicle(421,2000.9600,-1141.1925,25.1011,270.7406,149,149); // Glen Park Ballas car 7
    AddStaticVehicle(421,2011.6139,-1141.2915,24.8019,269.4290,149,149); // Glen Park Ballas car 8
    AddStaticVehicle(412,2206.0938,-1160.8945,25.4488,269.8322,6,6); // Vagos car 1
    AddStaticVehicle(412,2206.0903,-1165.0006,25.4463,271.1649,6,6); // Vagos car 2
    AddStaticVehicle(412,2206.0298,-1169.1166,25.4440,270.3391,6,6); // Vagos car 3
    AddStaticVehicle(412,2206.1631,-1173.0529,25.4428,269.3652,6,6); // Vagos car 4
    AddStaticVehicle(474,2227.8667,-1169.8987,25.4522,268.2267,6,6); // Vagos car 5
    AddStaticVehicle(474,2227.9622,-1166.4662,25.4632,270.1722,6,6); // Vagos car 6
    AddStaticVehicle(492,2246.2012,-1320.7792,23.6975,0.0065,86,86); // LS Church Grove Street car 1
    AddStaticVehicle(492,2241.0552,-1320.7288,23.7006,0.5121,86,86); // LS Church Grove Street car 2
    AddStaticVehicle(492,2236.2224,-1320.5066,23.6995,358.0996,86,86); // LS Church Grove Street car 3
    AddStaticVehicle(540,2243.1938,-1305.4990,23.6254,89.0592,86,86); // LS Church Grove Street car 4
    AddStaticVehicle(540,2228.4546,-1305.4347,23.6306,90.5938,86,86); // LS Church Grove Street car 5
    return 1;
}
public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    {
    SetPlayerCameraPos(playerid, 2220.9197,-1164.0920,25.7331);
    SetPlayerCameraLookAt(playerid, 2215.1963,-1164.0492,25.7266);
    SetPlayerPos(playerid, 2215.1963,-1164.0492,25.7266);
    SetPlayerFacingAngle(playerid, 270.5322);
    ApplyAnimation(playerid,"DANCING","DAN_LOOP_A",4.0,1,0,0,0,-1);
    PlayerPlaySound(playerid, 1183, 0.0, 0.0, 0.0);
    SetPlayerTeamFromClass(playerid, classid);
    }
    // Class select text
    if(classid == 102)
    {
        GameTextForPlayer(playerid,"~p~Ballas",3000,6);
    }
    else if(classid == 103)
    {
        GameTextForPlayer(playerid,"~p~Ballas",3000,6);
    }
    else if(classid == 104)
    {
        GameTextForPlayer(playerid,"~p~Ballas",3000,6);
    }
    else if(classid == 105)
    {
        GameTextForPlayer(playerid,"~g~Grove",3000,6);
    }
    else if(classid == 106)
    {
        GameTextForPlayer(playerid,"~g~Grove",3000,6);
    }
    else if(classid == 107)
    {
        GameTextForPlayer(playerid,"~g~Grove",3000,6);
    }
    else if(classid == 108)
    {
        GameTextForPlayer(playerid,"~y~Vagos",3000,6);
    }
    else if(classid == 109)
    {
        GameTextForPlayer(playerid,"~y~Vagos",3000,6);
    }
    else if(classid == 110)
    {
        GameTextForPlayer(playerid,"~y~Vagos",3000,6);
    }
    return 1;
}

    // Teams
    SetPlayerTeamFromClass(playerid, classid)
{
    {
    if (classid == 105)
        {
        gTeam[playerid] = TEAM_GROVE;
        return 1;
        }
    else if (classid == 106)
        {
        gTeam[playerid] = TEAM_GROVE;
        return 1;
        }
    else if (classid == 107)
        {
        gTeam[playerid] = TEAM_GROVE;
        return 1;
        }
    else if (classid == 102)
        {
        gTeam[playerid] = TEAM_BALLA;
        return 1;
        }
    else if (classid == 103)
        {
        gTeam[playerid] = TEAM_BALLA;
        return 1;
        }
    else if (classid == 104)
        {
        gTeam[playerid] = TEAM_BALLA;
        return 1;
        }
    else if (classid == 108)
        {
        gTeam[playerid] = TEAM_VAGO;
        return 1;
        }
    else if (classid == 109)
        {
        gTeam[playerid] = TEAM_VAGO;
        return 1;
        }
    else if (classid == 110)
        {
        gTeam[playerid] = TEAM_VAGO;
        return 1;
        }
    return 1;
    }
}
    // Team colors
    SetPlayerToTeamColor(playerid)
{
    if (gTeam[playerid] == TEAM_GROVE)
    {
        SetPlayerColor(playerid, TEAM_GROVE_COLOR);
    }
    else if (gTeam[playerid] == TEAM_BALLA)
    {
        SetPlayerColor(playerid, TEAM_BALLA_COLOR);
    }
    else if (gTeam[playerid] == TEAM_VAGO)
    {
        SetPlayerColor(playerid, TEAM_VAGO_COLOR);
    }
}
public OnPlayerConnect(playerid)
{
    return 1;
}

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

public OnPlayerSpawn(playerid)
{
    PlayerPlaySound( playerid, 1188, 0.0, 0.0, 0.0 );
    SetPlayerToTeamColor(playerid);
    return 1;
}

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

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

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

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply
#2

Fixed the formatting and switched that long if statement to a case. Updated link here. Looking for bugs now.

Edit: Fixed the script. Class IDs begin from 0 not 100, you can see the final working code here.
Reply
#3

Works perfectly, thanks
Reply
#4

Was looking into the color internal id's , thanks mate and keep up learning
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)