SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 29/05/2012, 11:34 AM   #1
Gangs_Rocks
Big Clucker
 
Join Date: Feb 2012
Location: Mars
Posts: 114
Reputation: 13
Default Making a simple Team Death Match

Oky, I'm gonna teach you how to make a simple TDM today.


Beginning


Before we start, We must define somethings for the sake of convenience:

pawn Code:
/* Under includes */

#define Criminals 1
#define Cops 2

#define CriminalsColor 0xFF0000AA
#define CopsColor 0x0015FFAA

Explanation:
We simply defined Criminals as the number 1 ( In this case, TEAM 1) and Cops as the number 2 ( In this case, TEAM 2) and defined CriminalsColor as RED ( 0xFF0000AA ) and CopsColor as BLUE ( 0x0015FFAA)

We're gonna use these later in our script.


Now, we're gonna set up 1 class for each team!

pawn Code:
// Under OnGameModeInIt //
AddPlayerClass(/* Cops Skin ID here */,/*Spawn Coords, Spawn Coords, Spawn Coords,Angle,Weapon 1,Weapon1amom,weapon2,weapon2ammo,weapon3,weapon3ammo*/);   
AddPlayerClass(/* Criminals Skin ID here */,/*Spawn Coords, Spawn Coords, Spawn Coords,Angle,Weapon 1,Weapon1amom,weapon2,weapon2ammo,weapon3,weapon3ammo*/);

Okay, we've set this up till now. But how will PAWNO know what class has what team? We'll have to do that now!
pawn Code:
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;
}

Okay, we're done but but but, Now we want to add the colors, and give special bonuses to different teams!

pawn Code:
/* OnPlayerSpawn */
    if(GetPlayerTeam(playerid) == Cops)
    {
        SetPlayerColor(playerid, CopsColor); // Set his color to CopsColor (BLUE)
           /* 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)
    }

What we did above was:

We checked WHAT team did the player belong to (SELECTED IN THE CLASS SELECTION) and according to that set his color, health, weapons etc. etc. etc. etc.


Now, we'll make some special features that be a must have in a TDM!


1. Random team spawns

Okay, this might seem complicated, but its quite simple. First of all, You just do one thing:

Go ingame, Do /save TEAMNAMERANDOMSPAWN1/2/3.
Do that for each team and have at least 2-3 spawn coords for each team.

Now using a random spawn array generator, Get the following codes. I'm not gonna teach you HOW to use the randomspawn array generator because this is meant to be a simple TDM, not an app usage tutorial.
BTW, I used this array generator: http://forum.sa-mp.com/showthread.php?t=199377
pawn Code:
new Float:CopRandomSpawns[4][3] = {
    {2494.8743,-1686.0897,13.5129},
    {2514.5706,-1672.4789,13.6054},
    {2487.3936,-1648.9874,13.6405},
    {2459.4307,-1689.4059,13.5369}
};


new Float:CriminalRandomSpawns[4][3] = {
    {2140.0620,-1699.6169,15.0784},
    {2166.7761,-1672.4318,15.0752},
    {2163.2312,-1659.7107,15.0859},
    {2173.2839,-1702.9806,14.3778}
};

Now you have the coords, you have everything, But you still can't enable the random spawns? We'll do that now:

We'll make custom functions for each team now :

pawn Code:
/// Outside all callbacks //
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;
}


Now, just add the following in our previous OnPlayerSpawn :

pawn Code:
/* OnPlayerSpawn */
    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
    }


2. The Team radio
pawn Code:
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;
}


Voila! Your TDM has got its base! You can do the rest yourself!

Last edited by Gangs_Rocks; 30/05/2012 at 07:24 AM.
Gangs_Rocks is offline   Reply With Quote
Old 29/05/2012, 12:00 PM   #2
[GF]Logic
Gangsta
 
[GF]Logic's Avatar
 
Join Date: Feb 2012
Posts: 497
Reputation: 27
Default Re: Making a simple Team Death Match

Great Job friend helped me alot Now thanks simple and good and you sound like a good teacher xD good job +Rep for effort and good tutorial
__________________
Quote:
If you won't Respect my Religion I won't respect your's
[GF]Logic is offline   Reply With Quote
Old 29/05/2012, 01:21 PM   #3
StrangeLove
Huge Clucker
 
StrangeLove's Avatar
 
Join Date: Nov 2011
Location: Philippines
Posts: 243
Reputation: 26
Default Re: Making a simple Team Death Match

Errors here

pawn Code:
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(75) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(75) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(81) : error 010: invalid function or declaration
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(87) : error 010: invalid function or declaration
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(105) : error 017: undefined symbol "SetPlayerRandomCopsSpawn"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(112) : error 017: undefined symbol "SetPlayerRandomCriminalsSpawn"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : error 017: undefined symbol "gTeam"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : warning 215: expression has no effect
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : error 001: expected token: ";", but found "]"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : 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.
__________________
Life is but a dream.
StrangeLove is offline   Reply With Quote
Old 29/05/2012, 02:05 PM   #4
Gangs_Rocks
Big Clucker
 
Join Date: Feb 2012
Location: Mars
Posts: 114
Reputation: 13
Default Re: Making a simple Team Death Match

Quote:
Originally Posted by MrSurfur1 View Post
Errors here

pawn Code:
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(75) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(75) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(81) : error 010: invalid function or declaration
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(87) : error 010: invalid function or declaration
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(105) : error 017: undefined symbol "SetPlayerRandomCopsSpawn"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(112) : error 017: undefined symbol "SetPlayerRandomCriminalsSpawn"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : error 017: undefined symbol "gTeam"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : warning 215: expression has no effect
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : error 001: expected token: ";", but found "]"
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : error 029: invalid expression, assumed zero
C:\Users\surfur1\Desktop\samp\gamemodes\copsvscriminals.pwn(142) : 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.

Okay, I need you to paste your code. + I fixed the gTeam thing, sorry, a little fail.

Also, @SetPlayerRandomCopsSpawn:

Remove the s after criminal and cop
Gangs_Rocks is offline   Reply With Quote
Old 30/05/2012, 04:27 AM   #5
StrangeLove
Huge Clucker
 
StrangeLove's Avatar
 
Join Date: Nov 2011
Location: Philippines
Posts: 243
Reputation: 26
Default Re: Making a simple Team Death Match

Here's my code:
pawn Code:
// 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 Code:
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.
__________________
Life is but a dream.
StrangeLove is offline   Reply With Quote
Old 30/05/2012, 07:23 AM   #6
Gangs_Rocks
Big Clucker
 
Join Date: Feb 2012
Location: Mars
Posts: 114
Reputation: 13
Default Re: Making a simple Team Death Match

pawn Code:
// 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

new Float:CopRandomSpawns[4][3] = {
    {2494.8743,-1686.0897,13.5129},
    {2514.5706,-1672.4789,13.6054},
    {2487.3936,-1648.9874,13.6405},
    {2459.4307,-1689.4059,13.5369}
};


new Float:CriminalRandomSpawns[4][3] = {
    {2140.0620,-1699.6169,15.0784},
    {2166.7761,-1672.4318,15.0752},
    {2163.2312,-1659.7107,15.0859},
    {2173.2839,-1702.9806,14.3778}
};


#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()
{
    // 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;
}


Mistakes you made:

You didn't ADD the array(s) of random spawns
You didn't define Cops and Criminals under includes
You fucked up your code by removing the #if defined filterscript and stuff.

Rest, I've fixed the brackets. Editing the tutorial
Gangs_Rocks is offline   Reply With Quote
Old 30/05/2012, 12:56 PM   #7
StrangeLove
Huge Clucker
 
StrangeLove's Avatar
 
Join Date: Nov 2011
Location: Philippines
Posts: 243
Reputation: 26
Default Re: Making a simple Team Death Match

Thank You!!!
__________________
Life is but a dream.

Last edited by StrangeLove; 30/05/2012 at 02:28 PM.
StrangeLove is offline   Reply With Quote
Old 31/05/2012, 05:38 AM   #8
StrangeLove
Huge Clucker
 
StrangeLove's Avatar
 
Join Date: Nov 2011
Location: Philippines
Posts: 243
Reputation: 26
Default Re: Making a simple Team Death Match

Anyways, how to make a command(zcmd) like /changeskin to go back to class selection?

Sorry for double post
__________________
Life is but a dream.

Last edited by StrangeLove; 31/05/2012 at 07:13 AM.
StrangeLove is offline   Reply With Quote
Old 31/05/2012, 08:42 AM   #9
JohnDoVaS12345
Big Clucker
 
Join Date: Jul 2010
Location: Greece
Posts: 97
Reputation: 5
Default Re: Making a simple Team Death Match

well i am a script learner donnot laugh at my fail plz :X

i need some help

Code:
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(71) : error 029: invalid expression, assumed zero
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(72) : error 029: invalid expression, assumed zero
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(89) : error 017: undefined symbol "Cops"
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(95) : error 017: undefined symbol "Criminals"
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(96) : warning 202: number of arguments does not match definition
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(99) : warning 217: loose indentation
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(113) : error 017: undefined symbol "Cops"
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(115) : error 017: undefined symbol "CopsColor"
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(116) : error 017: undefined symbol "SetPlayerCopsRandomSpawns"
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(120) : error 017: undefined symbol "Criminals"
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(122) : error 017: undefined symbol "CriminalsColor"
C:\Users\Giannis\Desktop\Testing SA-MP Server\filterscripts\TestTeamDM.pwn(123) : error 017: undefined symbol "SetPlayerCriminalRandomSpawns"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


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

#include <a_samp>

#if defined FILTERSCRIPT
#define Criminals 1
#define Cops 2

#define CriminalsColor 0xFF0000AA
#define CopsColor 0x0015FFAA

new Float:CopsRandomSpawns[3][3] = {
    {-2440.0681,1554.7762,2.1231},
    {-2432.7119,1541.5345,2.1172},
    {-2426.3713,1554.5654,5.0234}

new Float:CriminalRandomSpawns[3][3] = {
    {-2367.1274,1553.5460,2.1172},
    {-2371.1040,1544.6459,5.0234},
    {-2369.3916,1541.5813,7.9219},
};



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

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Team DeathMatch Filterscript");
	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
	AddPlayerClass(/* Cops Skin ID here */,/*Spawn Coords, Spawn Coords, Spawn Coords,Angle,Weapon 1,Weapon1amom,weapon2,weapon2ammo,weapon3,weapon3ammo*/);
	AddPlayerClass(/* Criminals Skin ID here */,/*Spawn Coords, Spawn Coords, Spawn Coords,Angle,Weapon 1,Weapon1amom,weapon2,weapon2ammo,weapon3,weapon3ammo*/);
	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)
        SetPlayerCopsRandomSpawns(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)
        SetPlayerCriminalRandomSpawns(playerid);///// Same as above
    }

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;
}
JohnDoVaS12345 is offline   Reply With Quote
Old 31/05/2012, 08:51 AM   #10
davve95
High-roller
 
davve95's Avatar
 
Join Date: Nov 2009
Location: Sweden
Posts: 3,849
Reputation: 234
Default Re: Making a simple Team Death Match

Seems useful I maybe gonna use it.. Lol I'm still abit beginner ^^...
davve95 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
[GameMode] [GM] SDM (Simple Death Match) v.1.1 ProRaiL Gamemode Scripts 7 05/07/2013 05:03 AM
Team Death Match Patrikas Scripting Help 4 29/05/2012 12:50 PM
Team Death Match pryor94 Scripting Help 3 29/05/2012 12:40 PM
[HELP] Team Death Match Please Help DaRkAnGeL[NBK] Scripting Help 0 08/10/2011 11:56 PM
[GameMode] Team Death Match DjAdy Gamemode Scripts 14 19/12/2010 12:38 PM


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


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