[Tutorial] Making a simple Team Death Match
#5

Here's my code:
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#define Criminals 1
#define Cops 2

#define CriminalsColor 0xFF0000AA
#define CopsColor 0x0015FFAA

#if defined FILTERSCRIPT

new Float:CopRandomSpawns[4][3] = {
    {2443.8242,107.5123,26.4779},
    {2450.9517,135.7147,26.9838},
    {2462.6238,130.7561,26.8490},
    {2462.6238,130.7561,26.8490}
};


new Float:CriminalRandomSpawns[4][3] = {
    {2266.6909,-76.9762,24.5859},
    {2255.8198,-73.7813,31.6016},
    {2266.3765,-72.2887,31.6016},
    {2266.3765,-72.2887,31.6016}
};

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()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(288,2462.5850,134.7622,27.6756,174.7096,3,99,29,5000,31,5000); //Cops
    AddPlayerClass(1,2339.9255,-134.3311,26.5491,358.7029,5,99,32,5000,30,5000);// Criminals
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
// So, we're gonna simply use a switch instead of if-else if structure

    switch(classid) // Switching between the classids
    {
         case 0(/* The first classid is of the cops*/):
         {
              SetPlayerTeam(playerid, Cops); // Setting players team
              GameTextForPlayer(playerid, "~b~Cops", 1000, 3); // Screen msg for player to show what team
          }

         case 1(/* The second classid is of the criminals*/):
         {
              SetPlayerTeam(playerid, Criminals); // Same as above
              GameTextForPlayer(playerid, "~r~Criminals, 1000", 3); // Same as above
          }
     }
     return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

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

public OnPlayerSpawn(playerid)
{
    if(GetPlayerTeam(playerid) == Cops)
    {
        SetPlayerColor(playerid, CopsColor); // Set his color to CopsColor (BLUE)
        SetPlayerRandomCopSpawn(playerid); /// NEW LINE! Enabling random spawns
           /* Any other bonus you want for Cops team! A special gun, skin, color, attachedobject, A random spawn! */
    }

    else if(GetPlayerTeam(playerid) ==Criminals)
    {
        SetPlayerColor(playerid, CriminalsColor);  // Same as above but in this case, CriminalsColor (RED)
        SetPlayerRandomCriminalSpawn(playerid);///// Same as above
    }
    return 1;
}

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

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

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

public OnPlayerText(playerid,text[])
{
    if(text[0] == ':') // : can be changed to whatever symbol u wanna use for player to enable the teamchat.
    {
        new string[128];  GetPlayerName(playerid, string, sizeof(string)); // Making the new's
        format(string, sizeof(string), "[Team Radio] %s: %s", string, text[1]); // Formatted the message
        printf("%s", string); // Printed it BOTH ingame + the server log

        for(new i = 0; i < MAX_PLAYERS; i++) // Getting the player team and color, required for formatting the msg.
        {
            if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid)) SendClientMessage(i, GetPlayerColor(playerid), string);
        }
        return 0;
    }

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

forward SetPlayerRandomCopSpawn(playerid); // Forwarding the function
public SetPlayerRandomCopSpawn(playerid) // Setting it up
{
    new rand = random(sizeof(CopRandomSpawns)); // Making it select random options instead of a definite one
    SetPlayerPos(playerid, CopRandomSpawns[rand][0], CopRandomSpawns[rand][1], CopRandomSpawns[rand][2]); // [rand] tag means random, [0] = X, [1] = Y, [2] = Z
    return 1;
}

/// Rest is same as above, just Cops replaced Criminals
forward SetPlayerRandomCriminalSpawn(playerid);
public SetPlayerRandomCriminalSpawn(playerid)
{
    new rand = random(sizeof(CriminalRandomSpawns));
    SetPlayerPos(playerid, CriminalRandomSpawns[rand][0], CriminalRandomSpawns[rand][1], CriminalRandomSpawns[rand][2]);
    return 1;
}
But I still got errors:
pawn Код:
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(74) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(74) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(80) : error 010: invalid function or declaration
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(86) : error 010: invalid function or declaration
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(297) : error 017: undefined symbol "CopRandomSpawns"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(297) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(297) : warning 215: expression has no effect
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(298) : error 017: undefined symbol "CopRandomSpawns"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(298) : warning 215: expression has no effect
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(298) : error 001: expected token: ";", but found "]"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(298) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminal.pwn(298) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


10 Errors.
Reply


Messages In This Thread
Making a simple Team Death Match - by Gangs_Rocks - 29.05.2012, 10:34
Re: Making a simple Team Death Match - by [GF]Logic - 29.05.2012, 11:00
Re: Making a simple Team Death Match - by StrangeLove - 29.05.2012, 12:21
Re: Making a simple Team Death Match - by Gangs_Rocks - 29.05.2012, 13:05
Re: Making a simple Team Death Match - by StrangeLove - 30.05.2012, 03:27
Re: Making a simple Team Death Match - by Gangs_Rocks - 30.05.2012, 06:23
Re: Making a simple Team Death Match - by StrangeLove - 30.05.2012, 11:56
Re: Making a simple Team Death Match - by StrangeLove - 31.05.2012, 04:38
Re: Making a simple Team Death Match - by JohnDoVaS12345 - 31.05.2012, 07:42
Re: Making a simple Team Death Match - by efrim123 - 28.09.2013, 01:59

Forum Jump:


Users browsing this thread: 1 Guest(s)