[Please Help] Heart pickups...
#1

ok, my code is:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
  if(pickupid == RedHeart)
  {
    if(gTeam[playerid] == TEAM_RED) return SetPlayerHealth(playerid, 100.0);
    if(gTeam[playerid] == TEAM_BLUE) return SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Red Team's health pickup...");
  }
   
  else if(pickupid == BlueHeart)
  {
    if(gTeam[playerid] == TEAM_BLUE) return SetPlayerHealth(playerid, 100.0);
    if(gTeam[playerid] == TEAM_RED) return SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Blue Team's health pickup...");
  }
   
 return 1;
}
I want to do, if RedHeart picks up Team blue send client message with text which is shown in the top...

if RedHearth picks up Team Red team member gets full health..
I get no errors when compiling, but when i enter RedHeart pickup with Team blue player gets full health and gets [ERROR] message, if with red everything is fine... how do i do, that everything would work?

please reply me quickly
Reply
#2



Try adding an else like so.
if(gTeam[playerid] == TEAM_RED) return SetPlayerHealth(playerid, 100.0);
else if(gTeam[playerid] == TEAM_BLUE) return SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Red Team's health pickup...");
Reply
#3

pawn Код:
if(gTeam[playerid] == TEAM_BLUE)
{
  SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Red Team's health pickup...");
  return 0;
}

if(gTeam[playerid] == TEAM_RED)
{
  SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Blue Team's health pickup...");
  return 1; // if it doesnt work, try return 0;
}

return 0;
}
Reply
#4

the same stuff happens...
Reply
#5

Quote:
Originally Posted by Mikkel
pawn Код:
if(gTeam[playerid] == TEAM_BLUE)
{
  SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Red Team's health pickup...");
  return 0;
}

if(gTeam[playerid] == TEAM_RED)
{
  SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Blue Team's health pickup...");
  return 1; // if it doesnt work, try return 0;
}

return 0;
}
trying now..
Reply
#6


pawn Код:
if(pickupid == RedHeart)
    {
        if(gTeam[playerid] == TEAM_RED)
        {
            SetPlayerHealth(playerid, 100.0);
            return 1;
        }
        if(gTeam[playerid] == TEAM_BLUE)
        {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Red Team's health pickup...");
            return 1;
        }
    }
   
    if(pickupid == BlueHeart)
    {
        if(gTeam[playerid] == TEAM_BLUE)
        {
            SetPlayerHealth(playerid, 100.0);
            return 1;
        }
        if(gTeam[playerid] == TEAM_RED)
        {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Blue Team's health pickup...");
            return 1; // return 0 does not work to..
        }
    }
What do I do?
Reply
#7

I can only assume there's a problem with the way the teams are set up?
Reply
#8

pawn Код:
#include <a_samp>

#define TEAM_RED 1
#define TEAM_COLOR_RED COLOR_DARK_RED
#define TEAM_BLUE 2
#define TEAM_COLOR_BLUE COLOR_DARK_BLUE

#define COLOR_DARK_RED 0x700000AA
#define COLOR_DARK_BLUE 0x000069AA

#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000F6AA
#define COLOR_GREEN 0x33FF33AA
#define COLOR_DARK_GREEN 0x6D9000AA

new gTeam[MAX_PLAYERS];
new Sniper;
new RedHeart;
new BlueHeart;


main()
{
    print("Ultimate TDM by Alive Launched...");
}

public OnGameModeInit()
{
    SetGameModeText("Ultimate TDM");
    UsePlayerPedAnims();

    Sniper = CreatePickup(358, 2, -812.1102, 2750.7627, 73.2797);

    RedHeart = CreatePickup(1240, 2, -812.2223, 2766.4456, 63.7689);
    BlueHeart = CreatePickup(1240, 2, -808.6461, 2735.1990, 63.7924);

    AddPlayerClass(0,-796.8313,2815.6621,71.8465,93.4485,0,0,0,0,0,0); // TEAM RED
    AddPlayerClass(299,-798.0907,2692.8171,71.8808,90.9418,0,0,0,0,0,0); // TEAM BLUE

    CreateObject(8417, -812.671143, 2689.990234, 70.745613, 0, 179.622440866, 0); // object (4)
    CreateObject(8417, -812.528870, 2800.358887, 70.703995, 0, 179.622440866, 0); // object (5)
    CreateObject(8417, -812.680664, 2706.629639, 70.719994, 0, 179.622440866, 0); // object (6)
    CreateObject(8417, -812.535217, 2818.949707, 70.513741, 89.3813588468, 179.622440866, 0); // object (9)
    CreateObject(8417, -812.794495, 2689.355957, 71.492943, 89.3813588468, 179.622440866, -180.000020054); // object (10)
    CreateObject(8210, -832.838684, 2808.268799, 73.719978, 0, 0, -89.9999813789); // object (15)
    CreateObject(8210, -792.242737, 2808.004639, 73.978264, 0, 0, -270.000001432); // object (16)
    CreateObject(8210, -792.424194, 2698.727051, 73.991264, 0, 0, -270.000001432); // object (17)
    CreateObject(8210, -833.013550, 2698.985352, 73.753464, 0, 0, -89.9999813789); // object (18)
    CreateObject(8417, -812.528137, 2746.643311, 62.727783, 0, 179.622440866, 0); // object (19)
    CreateObject(8210, -832.878235, 2753.163818, 65.736572, 0, 0, -89.9999813789); // object (20)
    CreateObject(8210, -833.022095, 2753.153320, 73.732613, 0, 0, -89.9999813789); // object (21)
    CreateObject(8210, -792.242126, 2753.504150, 66.000069, 0, 0, -270.000001432); // object (22)
    CreateObject(8210, -792.234802, 2753.519287, 73.978432, 0, 0, -270.000001432); // object (23)
    CreateObject(8210, -813.787720, 2726.775635, 64.935013, 0, 0, -360.000040107); // object (25)
    CreateObject(8417, -812.538391, 2761.430908, 62.725014, 0, 179.622440866, 0); // object (26)
    CreateObject(8210, -814.289124, 2780.182129, 64.921417, 0, 0, -539.999888273); // object (27)
    CreateObject(12918, -800.608032, 2783.020996, 70.615738, 0, 0, -180.859399451); // object (28)
    CreateObject(12918, -812.611938, 2783.190674, 70.611969, 0, 0, -180.859399451); // object (29)
    CreateObject(12918, -824.592224, 2783.367432, 70.632370, 0, 0, -180.859399451); // object (30)
    CreateObject(12918, -824.733826, 2724.657959, 70.672279, 0, 0, -360.859304913); // object (31)
    CreateObject(12918, -812.757690, 2724.494873, 70.673889, 0, 0, -360.859304913); // object (32)
    CreateObject(12918, -801.110535, 2724.322266, 70.677948, 0, 0, -360.859304913); // object (33)
    CreateObject(17058, -811.407837, 2750.804688, 62.755844, 0, 0, 0); // object (35)
    CreateObject(13645, -821.893921, 2751.205322, 66.881577, 0, 0, 0); // object (38)
    CreateObject(13645, -821.875427, 2750.674316, 66.881516, 0, 0, -180.000020054); // object (39)
    CreateObject(13645, -811.289246, 2751.121582, 66.881516, 0, 0, 0); // object (40)
    CreateObject(13645, -811.247681, 2750.510742, 66.875252, 0, 0, -180.000020054); // object (41)
    CreateObject(13645, -801.431519, 2751.032471, 66.901070, 0, 0, 0); // object (42)
    CreateObject(13645, -801.406738, 2750.318115, 66.881516, 0, 0, -180.000020054); // object (43)
    CreateObject(8572, -795.486633, 2748.945068, 65.078156, 0, 0, -270.000001432); // object (48)
    CreateObject(8572, -827.289307, 2752.746582, 65.070404, 0, 0, -449.99996419); // object (49)
    CreateObject(17950, -796.447205, 2815.272217, 72.890785, 0, 0, 89.9999813789); // object (51)
    CreateObject(17950, -828.688660, 2815.365723, 72.699753, 0, 0, -89.9999813789); // object (52)
    CreateObject(17950, -796.546265, 2692.901611, 72.940605, 0, 0, 89.9999813789); // object (53)
    CreateObject(17950, -828.841187, 2693.126221, 72.684875, 0, 0, -89.9999813789); // object (54)
    CreateObject(11442, -812.426147, 2706.922852, 70.960045, 0, 0, -179.999962758); // object (56)
    CreateObject(11442, -811.639587, 2801.848145, 70.922668, 0, 0, 0); // object (57)
    CreateObject(11443, -799.262634, 2798.806152, 71.002228, 0, 0, 0); // object (58)
    CreateObject(11443, -822.692017, 2710.349609, 70.864830, 0, 0, -179.999962758); // object (59)
    CreateObject(11441, -800.737671, 2708.776123, 71.038223, 0, 0, 0); // object (60)
    CreateObject(11441, -824.735046, 2798.493896, 70.837524, 0, 0, -180.000020054); // object (61)

    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
  if(classid == 0)
  {
    gTeam[playerid] = TEAM_RED;
        GameTextForPlayer(playerid,"~y~Team ~b~~n~BLUE",1000,4);
  }
  else if(classid == 1)
  {
    gTeam[playerid] = TEAM_BLUE;
    GameTextForPlayer(playerid,"~y~Team ~r~~n~RED",1000,4);
  }
}

SetPlayerToTeamColour(playerid)
{
  if(gTeam[playerid] == TEAM_RED)
  {
    SetPlayerColor(playerid,TEAM_COLOR_RED);
  }
  else if(gTeam[playerid] == TEAM_BLUE)
  {
    SetPlayerColor(playerid,TEAM_COLOR_BLUE);
  }
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid,1541.2833, -1362.4741, 329.6457);
    SetPlayerCameraLookAt(playerid,1541.2833, -1362.4741, 329.6457);
    SetPlayerCameraPos(playerid,1540.8374,-1358.4910,329.4645);
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
  SetPlayerToTeamColour(playerid);
  if(GetPlayerSkin(playerid) == 0)
  {
    SetPlayerArmour(playerid,100);
    }
    if(GetPlayerSkin(playerid) == 299)
  {
    SetPlayerArmour(playerid,100);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid,COLOR_DARK_GREEN,"Welcome to Ultimate Team Death Match");
    SendClientMessage(playerid,COLOR_DARK_GREEN,"...this server was made by Alive");
    SendClientMessage(playerid,COLOR_DARK_GREEN,"For a list of commands just type /cmds");
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_RED)
    {
        SendClientMessage(playerid, COLOR_RED, "Your objective is to kill as more BLUE team members as you can.");
    }
    else if(gTeam[playerid] == TEAM_BLUE)
    {
        SendClientMessage(playerid, COLOR_BLUE, "Your objective is to kill as more RED team members as you can.");
    }
   
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == Sniper)
    {
        GivePlayerWeapon(playerid, 34, 50);
        SendClientMessage(playerid, COLOR_GREEN, "[SUCESS]Sniper picked up");
    }

    if(pickupid == RedHeart)
    {
        if(gTeam[playerid] == TEAM_RED)
        {
            SetPlayerHealth(playerid, 100.0);
            return 1;
        }
        if(gTeam[playerid] == TEAM_BLUE)
        {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Red Team's health pickup...");
            return 1;
        }
    }
   
    if(pickupid == BlueHeart)
    {
        if(gTeam[playerid] == TEAM_BLUE)
        {
            SetPlayerHealth(playerid, 100.0);
            return 1;
        }
        if(gTeam[playerid] == TEAM_RED)
        {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]This is Blue Team's health pickup...");
            return 1;
        }
    }
    return 1;
}
whats wrong? i dont think it is bad...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)