Teams and teams vehicles, need help.
#1

So I used this tutorial to create teams and their vehicles on my server.
I have followed every single step and changed the team names to my own.
However it gives me the following errors when compiling:

Quote:

C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(9) : error 017: undefined symbol "TeamCars"
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(9) : error 009: invalid array size (negative, zero or out of bounds)
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(48 ) : warning 213: tag mismatch
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(49) : warning 213: tag mismatch
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(254) : error 054: unmatched closing brace ("}")
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(265) : error 054: unmatched closing brace ("}")
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(268 ) : error 021: symbol already defined: "OnPlayerStateChange"
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(272) : warning 213: tag mismatch
C:\Documents and Settings\test\Bureaublad\FCCRP\gamemodes\FCCRP2.pw n(281) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.

And this is my script:

pawn Код:
#include <a_samp>

#define POLICE 1
#define EMS 2
#define POLICE_COLOR 0x1B4CE0AA
#define EMS_COLOR 0xFF8AF5AA
#define COLOR_RED 0xFF0000AA

new Cars[TeamCars];
enum TeamCars
{
Police,
Ems
}

new gTeam[MAX_PLAYERS];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    AddPlayerClass(282,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //POLICE
    AddPlayerClass(275,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //EMS
    Cars[Police] = AddStaticVehicle(598,-210.8453,999.8466,19.3565,88.9803,0,1); // FCpolice1
    Cars[Ems] = AddStaticVehicle(416,-330.7315,1063.7899,19.8899,270.1239,1,3); // FCems1
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

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

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(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;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = POLICE;
    }
    if(classid == 1)
        gTeam[playerid] = EMS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOR); //BLUE
    }
    if(gTeam[playerid] == EMS)
        SetPlayerColor(playerid,EMS_COLOR); // PINK
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[Police] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        if(CarCheck == Cars[Ems] )
        {
            if(gTeam[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}

Any help would be greatly appreciated.
Also sorry if the errors made are obvious and nooby, I'm new to this all.
Reply
#2

pawn Код:
#include <a_samp>

#define COLOR_RED 0xFF0000AA

enum Teams {
    tPolice,
    tEms
}

stock const TeamColors[Teams] = {
    0x1B4CE0AA,
    0xFF8AF5AA
};

new
    Teams: gTeam[MAX_PLAYERS char],
    Teams: gTeamVehicle[(MAX_VEHICLES + 1) char]
;

main() {
    print("\nBlank Gamemode by your name here\n");
}

public OnGameModeInit() {
    AddPlayerClass(282,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //POLICE
    AddPlayerClass(275,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //EMS

    SetVehicleToTeam(tPolice, AddStaticVehicle(598,-210.8453,999.8466,19.3565,88.9803,0,1)); // FCpolice1
    SetVehicleToTeam(tEms, AddStaticVehicle(416,-330.7315,1063.7899,19.8899,270.1239,1,3)); // FCems1
}

stock SetVehicleToTeam(Teams: teamid, vehicleid) {
    if(0 < vehicleid < sizeof gTeamVehicle) {
        gTeamVehicle{vehicleid} = teamid;
        return true;
    }
    return false;
}

public OnPlayerRequestClass(playerid, classid) {
    switch(classid) {
        case 0: gTeam{playerid} = tPolice;
        case 1: gTeam{playerid} = tEms;
    }
    return true;
}

public OnPlayerSpawn(playerid) {
    SetPlayerColor(playerid, TeamColors[gTeam{playerid}]);
    return true;
}

public OnPlayerStateChange(playerid, newstate, oldstate) {
    if(newstate == PLAYER_STATE_DRIVER) {
        new
            vehicleid = GetPlayerVehicleID(playerid)
        ;
        if(gTeam{playerid} != gTeamVehicle{vehicleid}) {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
            return true;
        }
    }
    return true;
}
Reply
#3

I appreciate you trying to help me but if it's possible I would like to stick to the tutorial method, as you gave no explanation on why you made above changes.
Reply
#4

First I removed all unused callbacks like that
pawn Код:
#include <a_samp>

#define POLICE 1
#define EMS 2
#define POLICE_COLOR 0x1B4CE0AA
#define EMS_COLOR 0xFF8AF5AA
#define COLOR_RED 0xFF0000AA

new Cars[TeamCars];
enum TeamCars
{
Police,
Ems
}

new gTeam[MAX_PLAYERS];

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    AddPlayerClass(282,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //POLICE
    AddPlayerClass(275,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //EMS
    Cars[Police] = AddStaticVehicle(598,-210.8453,999.8466,19.3565,88.9803,0,1); // FCpolice1
    Cars[Ems] = AddStaticVehicle(416,-330.7315,1063.7899,19.8899,270.1239,1,3); // FCems1
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = POLICE;
    }
    if(classid == 1)
        gTeam[playerid] = EMS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOR); //BLUE
    }
    if(gTeam[playerid] == EMS)
        SetPlayerColor(playerid,EMS_COLOR); // PINK
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[Police] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        if(CarCheck == Cars[Ems] )
        {
            if(gTeam[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Through that you get rid of the the error 021: symbol already defined: "OnPlayerStateChange" because you got that public twice in your code

Than I just moved the enum TeamCars over the Cars array, that will solve all other errors and will only leave the two error 054
pawn Код:
enum TeamCars
{
Police,
Ems
}
new Cars[TeamCars];
These are caused in SetPlayerToTeamColour and SetPlayerTeamFromClass trough the missing opening bracket at the second if statement
pawn Код:
//SetPlayerTeamFromClass
if(classid == 1) // missing {
    gTeam[playerid] = EMS;
}
//SetPlayerTeamFromClass
if(gTeam[playerid] == EMS) // missing {
    SetPlayerColor(playerid,EMS_COLOR); // PINK
}
That wont result in the code I posted above but will fix your errors and warnings
I just rewrote some things to make it more effective and easier to use but its not beginner friendly
Reply
#5

Never mind what I jus said! Fixed it thanks to you. Thanks a lot man.
Reply
#6

Last question I have with this; How do I add more skins to one specific team?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)