• Welcome to Vice City Multiplayer.
 

Last Man Stading by Madara ( !lms, !join, !playersinlms ) (Fixed)

Started by Madara, March 19, 2011, 09:20:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madara

Many ask, how to make a LMS for my server?, well, here I show you a way to haer a man last Stading created by me.

First of all, define the locations used in the game last man standing, it will stop positions, but they better save their time and give them that I have.
new Float:RandInfoLMS[15][7] = { // MinX, MaxX, MinY, MaxY , X , Y , Z , Int
{-1102.2737,-1075.0229,1267.8066,1393.5516,-1094.28332519, 1307.67419433, 34.24106979},
{-1708.7883, -1540.6664, -524.5789, -463.3878, -1635.2369, -501.1630, 50.1828},
{-1013.4427, -924.8788, 698.5222, 777.5504, -969.2894, 743.3184, 57.2507},
{-833.6387, -754.4878, 806.6534, 855.1415, -804.1165, 815.6527, 11.0846},
{542.0474, 590.8376, -110.5802, -70.8055, 568.1187, -84.2334, 9.4397},
{91.7778, 167.5648, 329.0602, 357.0180, 128.2160, 343.1032, 19.1541},
{-44.6020, -27.4109, 1178.2372, 1213.4877, -37.6370, 1197.8688, 21.4526},
{-1200.9607, -1167.4662, -1349.8386, -1312.9932, -1183.3875, -1334.0931, 14.9360},
{-1107.7136, -1057.4801, -288.9542, -239.3820, -1081.9669, -262.2973, 20.4579},
{-1107.7972, -1069.2410, -634.8514, -594.0654, -1090.0913, -616.2128, 11.2534},
{-1003.6110, -955.4279, 96.3539, 142.3303, -978.6742, 119.9475, 9.2628},
{-998.5562, -902.6942, 369.7229, 427.0913, -954.6682, 397.8014, 11.2516},
{196.3628, 236.3812, -1297.0651, -1252.8628, 230.3235, -1266.7476, 20.1141},
{98.4118, 135.2352, -1340.5229, -1308.0060, 121.8333, -1328.8723, 4.4396},
{-18.8285, 27.5851, -949.9951, -927.9282, 4.2093, -941.0284, 16.1160}
};


Then we define another to be the same, but this will be the reward it received the game winner last man standing:
new RandRewardLMS[10][1] = {
{500},
{1500},
{3000},
{4500},
{6000},
{7500},
{9000},
{12500},
{16000},
{25000}
};


Now we will create two stored data enumerators, one will be to define a player, and other free information that will serve to guard the last man standing ticket:

enum LMSInfo
{
OnLMS,
LockLMS,
CountLMS,
Float:MinXS,
Float:MaxXS,
Float:MinYS,
Float:MaxYS,
Float:PosXS,
Float:PosYS,
Float:PosZS,
IntS,
RewS,
CDLMS,
WinnerS[256],
}

//And this:

enum playerInfoLMS
{
JoinLMS,
Float:pX,
Float:pY,
Float:pZ,
       LastVehicle,
}


Once employed these, we place the new letters that are combined with the enumeration of these two mentioned, remember, all this must go up:

new pInfoLMS[MAX_PLAYERS][playerInfoLMS];
new gLMS[LMSInfo], MSGLMS[256], LMS1;


After that, look for the "public OnPlayerDisconnect (playerid, reason)" and put it in an empty line, which can be used so that when a player leaves the server, and the full play the last man standing, you remove the ticket and decrease the number of players in the last man standing:

public OnPlayerDisconnect(playerid, reason)
{
       if (pInfoLMS[playerid][JoinLMS] == 1) {pInfoLMS[playerid][JoinLMS] = 0; DecLMSCount(1);}
return 1;
}


Now create the script! lms and! more besides join a checker who are playing the last man standing and how many are:

public OnPlayerText(playerid, cmdtext[])
{

   if (strcmp(cmd, "!lms", true) == 0) {
if(gLMS[OnLMS] == 1) SendClientMessage(playerid, 0x04A36BFF,"[Error] - Last Man Standing currently activated.");
else {
                    StarLMS();
}
return 1;
   }

   else if (strcmp(cmd, "!join", true) == 0) {
if(gLMS[OnLMS] == 0) SendClientMessage(playerid, 0x04A36BFF,"[Error] - Last Man Standing currently disabled.");
else if(pInfoLMS[playerid][JoinLMS] == 1) SendClientMessage(playerid, 0x04A36BFF,"[Error] - You are already in Last Man Standing.");
else if(gLMS[LockLMS] == 1) SendClientMessage(playerid, 0x04A36BFF,"[Error] - You can't enter the Last Man Standing.");
else {
    JoinPlayerLMS(playerid);
}
return 1;
   }

   else if (strcmp(cmd, "!playerslms", true) == 0) {
       new Count, i;
       for (i = 0; i <= MAX_PLAYERS; i ++) if(IsPlayerConnected(i) && pInfoLMS[i][JoinLMS] == 1) Count++;
       if (Count >= 1) {
                new bool:b = false;
                for (i = 0; i <= MAX_PLAYERS; i ++) if(IsPlayerConnected(i) && pInfoLMS[i][JoinLMS] == 1) {
                if(!b) {format(MSGLMS,256,"%s",PlayerName(i)); b = true;}
                else format(MSGLMS,256,"%s - %s",MSGLMS,PlayerName(i));
                }
}
if (Count >= 1) {format(MSGLMS,256, "Players in LMS: %s.",MSGLMS); SendClientMessageToAll(0x377DFFFF,MSGLMS); format(MSGLMS, 256, "Total players LMS: %d.",GetLMSCount()); SendClientMessageToAll(0x377DFFFF,MSGLMS);}
else SendClientMessageToAll(0x377DFFFF, "No players currently in LMS.");
return 1;
   }

   return 0;
}


Then we move into the public "OnPlayerDeath (playerid, killerid, reason, bodypart)," that there will a line when a player dies it decreases the number of players in lms and you take your ticket you have in combat:

public OnPlayerDeath(playerid, killerid, reason, bodypart)
{        
     if ( reason == reason ) {
         if (pInfoLMS[playerid][JoinLMS] == 1) {pInfoLMS[playerid][JoinLMS] = 0; DecLMSCount(1);}
     }
     return 1;
}


If you noticed, in the above commands:! lms and! join, there are two functions that are JoinPlayerLMS StarLMS and the first is to create all the data using defined at the outset, filled out the location of the combat and reward, and the second is to fill in data when active player! join and enter the battle, but the weapon is removed and temporarily frozen, remember that when they do new function using "public ", define the way down and without intervention from others.

public StarLMS()
{
   new rand1 = random(sizeof(RandInfoLMS)), rand2 = random(sizeof(RandRewardLMS));
   new Float:x, Float:y, Float:z, Float:MinX, Float:MaxX, Float:MinY, Float:MaxY;
   MinX = RandInfoLMS[rand1][0],MaxX = RandInfoLMS[rand1][1],MinY = RandInfoLMS[rand1][2],MaxY = RandInfoLMS[rand1][3];
   x = RandInfoLMS[rand1][4],y = RandInfoLMS[rand1][5],z = RandInfoLMS[rand1][6];
   gLMS[MinXS] = MinX, gLMS[MaxXS] = MaxX, gLMS[MinYS] = MinY, gLMS[MaxYS] = MaxY;
   gLMS[PosXS] = x, gLMS[PosYS] = y, gLMS[PosZS] = z, gLMS[RewS] = RandRewardLMS[rand2][0], gLMS[OnLMS] = 1;
   SetTimer("CloseJoinLMS",20000,0);
   SendClientMessageToAll(0x377DFFFF,"LMS Activate, type !join to enter, wait players [20 Seg.]");
   return 1;
}

public JoinPlayerLMS(playerid)
{
   new Float:x, Float:y, Float:z;
   SendClientMessage(playerid, 0x04A36BFF,"Joined to Last Man Standing, waiting more players...");
   GetPlayerPos(playerid,x,y,z);
   IncLMSCount(1);
   TogglePlayerControllable(playerid,0);
   ResetPlayerWeapons(playerid);
   format(MSGLMS,256,"%s",PlayerName(playerid));
   pInfoLMS[playerid][pX] = x, pInfoLMS[playerid][pY] = y, pInfoLMS[playerid][pZ] = z;
   pInfoLMS[playerid][JoinLMS] = 1;
   SetPlayerPos(playerid,gLMS[PosXS], gLMS[PosYS], gLMS[PosZS], 0,0);
   if (IsPlayerInAnyVehicle(playerid)) pInfoLMS[playerid][LastVehicle] = GetPlayerVehicleID(playerid);
   return 1;
}


Now add this as a timer function that the StarLMS, which closes the entrance to the LMS and deny entry to those who want to go putting! join, and also send the countdown to begin the fight:

public CloseJoinLMS()
{
   if (gLMS[CountLMS] == 0) {SendClientMessageToAll(0x377DFFFF, "LMS has closed because no players."); SetTimer("QuitBugLMS",1000,0);}
   if (gLMS[CountLMS] == 1) {SendClientMessageToAll(0x377DFFFF, "LMS has closed because need more players."); QuitPlayerLMS();}
   else if (gLMS[CountLMS] >= 2) {
                SendClientMessageToAll(0x377DFFFF, "LMS is now closed, you can't get at moment.");
                SendClientMessageToAll(0x377DFFFF, "Starting the game Last Man Standing.");
gLMS[LockLMS] = 1;
        SetTimer("CountLMS1", 1000, 0);
SetTimer("CountLMS2", 2000, 0);
  SetTimer("CountLMS3", 3000, 0);
SetTimer("CountLMS4", 4000, 0);
   }
   return 1;
}




public StarGameLMS()
{
   if (gLMS[CountLMS] == 0) {SendClientMessageToAll(0x377DFFFF, "LMS has ended because no players."); KillTimer(LMS1); SetTimer("QuitBugLMS",1000,0);}
   else if (gLMS[CountLMS] == 1) {SendClientMessageToAll(0x377DFFFF, "LMS has completed and a winner."); KillTimer(LMS1); SetTimer("InfoPlayerWinLMS",500,0); SetTimer("SendPlayerRewardLMS",1000,0);}
   else if (gLMS[CountLMS] >= 2) {
        for(new i = 0; i <= MAX_PLAYERS; i++) {
            new plr = FindPlayerIDFromString(PlayerName(i));
            if(pInfoLMS[plr][JoinLMS] == 1){
               if(!NeedPlayerInArea(plr,gLMS[MinXS],gLMS[MaxXS],gLMS[MinYS],gLMS[MaxYS])) {SetPlayerPos(plr,gLMS[PosXS], gLMS[PosYS], gLMS[PosZS], 0,0); GameTextForPlayerBottom(plr,"~h~re-join!");}
               else GameTextForPlayerBottom(plr,"\x10");
            }
}
}
return 1;
}




public QuitPlayerLMS()
{
   SetTimer("QuitBugLMS",2000,0);
   for(new i = 0; i <= MAX_PLAYERS; i++) {
       new plr = FindPlayerIDFromString(PlayerName(i));
       if(pInfoLMS[plr][JoinLMS] == 1){
          gLMS[LockLMS] = 0, gLMS[OnLMS] = 0, pInfoLMS[plr][JoinLMS] = 0;
          TogglePlayerControllable(plr,1);
          SetPlayerWeapon(plr,19,9999);
      SetPlayerWeapon(plr,22,9999);
      SetPlayerWeapon(plr,32,9999);
      DecLMSCount(1);
      if (pInfoLMS[plr][LastVehicle] >= 1) {PutDirectlyInVehicle(plr,pInfoLMS[plr][LastVehicle]); pInfoLMS[plr][LastVehicle] = 0;}
      else SetPlayerPos(plr,pInfoLMS[plr][pX],pInfoLMS[plr][pY],pInfoLMS[plr][pZ],0,0);
       }
   }
   return 1;
}




public QuitBugLMS()
{
   gLMS[LockLMS] = 0;
   gLMS[OnLMS] = 0;
   gLMS[CountLMS] = 0;
}



public InfoPlayerWinLMS()
{
   gLMS[LockLMS] = 0, gLMS[OnLMS] = 0, gLMS[CountLMS] = 0;
   for(new i = 0; i <= MAX_PLAYERS; i++) {
       new plr = FindPlayerIDFromString(PlayerName(i));
       if(pInfoLMS[plr][JoinLMS] == 1){
  format(MSGLMS,256,"%s",PlayerName(plr));
          gLMS[WinnerS] = MSGLMS;
          }
   }
   return 1;
}





public SendPlayerRewardLMS()
{
   new plr = FindPlayerIDFromString(gLMS[WinnerS]);
   format(MSGLMS,256,"~h~ LMS winner: ~o~%s",PlayerName(plr));
   GameTextForAll(MSGLMS);
   format(MSGLMS,256, "%s is the winner of LMS, Reward:$ %d.",PlayerName(plr),gLMS[RewS]);
   SendClientMessageToAll(0x377DFFFF,MSGLMS);
   GivePlayerMoney(plr,gLMS[RewS]); // <--- Here put u cash or type function use to send money player
   SetPlayerWeapon(plr,15,9999);
   SetPlayerWeapon(plr,17,9999);
   SetPlayerWeapon(plr,29,9999);
   SetPlayerPos(plr,pInfoLMS[plr][pX],pInfoLMS[plr][pY],pInfoLMS[plr][pZ],0,0);
   pInfoLMS[plr][JoinLMS] = 0;
SetTimer("QuitBugLMS",1000,0);
if (pInfoLMS[plr][LastVehicle] >= 1) {PutDirectlyInVehicle(plr,pInfoLMS[plr][LastVehicle]); pInfoLMS[plr][LastVehicle] = 0;}
else SetPlayerPos(plr,pInfoLMS[plr][pX],pInfoLMS[plr][pY],pInfoLMS[plr][pZ],0,0);
}





public CountLMS1()
{
   for(new i = 0; i <= MAX_PLAYERS; i++) {
   new plr = FindPlayerIDFromString(PlayerName(i));
   if(pInfoLMS[plr][JoinLMS] == 1){
  GameTextForPlayer(plr,"~b~-~y~ 3 ~b~-");
 }
  }
  return 1;
}

public CountLMS2()
{
   for(new i = 0; i <= MAX_PLAYERS; i++) {
   new plr = FindPlayerIDFromString(PlayerName(i));
   if(pInfoLMS[plr][JoinLMS] == 1){
  GameTextForPlayer(plr,"~b~-~x~ 2 ~b~-");
 }
  }
  return 1;
}

public CountLMS3()
{
   for(new i = 0; i <= MAX_PLAYERS; i++) {
   new plr = FindPlayerIDFromString(PlayerName(i));
   if(pInfoLMS[plr][JoinLMS] == 1){
  GameTextForPlayer(plr,"~b~-~h~ 1 ~b~-");
 }
  }
  return 1;
}

public CountLMS4()
{
   LMS1 = SetTimer("StarGameLMS",1000,1);
   for(new i = 0; i <= MAX_PLAYERS; i++) {
   
   new plr = FindPlayerIDFromString(PlayerName(i));
   if(pInfoLMS[i][JoinLMS] == 1){
         GameTextForPlayer(plr,"~b~- ~o~Go! Go! Go! ~b~-");
         SetPlayerWeapon(plr,21,9999);
         SetPlayerWeapon(plr,23,9999);
         SetPlayerWeapon(plr,32,9999);
         SetPlayerHealth(plr,100.0);
         TogglePlayerControllable(plr,1);
         }
}
return 1;
}




public GetLMSCount()
{
return gLMS[CountLMS];
}

public IncLMSCount(amount)
{
gLMS[CountLMS] = gLMS[CountLMS] + amount;
}

public DecLMSCount(amount)
{
gLMS[CountLMS] = gLMS[CountLMS] - amount;
}





stock NeedPlayerInArea(playerid,Float:MinX,Float:MaxX,Float:MinY,Float:MaxY)
{
      new Float:x,Float:y,Float:z;
      GetPlayerPos(playerid, x, y, z);
      if(x >= MinX && x <= MaxX && y >= MinY && y <= MaxY) return 1;
      else return 0;
      return 1;
}


And define this function, if not existe:

stock PlayerName(playerid)
{
     new name[24];
     GetPlayerName(playerid,name,24);
     return name;
}


    - OPTION 2 -
If they fail to put the codes right into your script, you can choose to lower my filterscript and add it to your server.

This filterscript filterscripts put it in the folder (if any) and if there add it, then you put in your server.cfg that is where your server, and inside it, add a line (if there) and named filterscripts below this the filter name "LMS".

   DOWNLOAD:Filterscript LMS to Mediafire  &&  Filterscript LMS to Megaupload

And that's all, for any questions or suggestions, let me know and we will gladly assist you.

Credits: YO ( Madara ).
MSN: [email protected]

Greetings. :D

yazeen

YOur the best scripter NICEEEEEEEE
What is lms? maze?



yazeen