Random spawn and another thing ...
#1

hi everyone, i need a random spawn, i mean it's not working...
I have this:

(1) Random spawn [SOLVED]
It's a code from my derby server, so it's with a round timer.
pawn Код:
new OtherSpawn = random(3);
        switch (OtherSpawn)
        {
            case 0:
            {
                SetPlayerPos(playerid, 1369.2378,2195.9094,9.7578);
                TogglePlayerSpectating(playerid, 0);
            }
            case 1:
            {
                SetPlayerPos(playerid, 2897.8269,529.6500,2.5237);
                TogglePlayerSpectating(playerid, 0);
            }
            case 2:
            {
                SetPlayerPos(playerid, -1164.3026,-927.6463,129.2188);
                TogglePlayerSpectating(playerid, 0);
            }
        }
At this if the rounds end, i don't go to another position im staying at the same place.
And i think too ... not everyone is going to the same place, i mean if the rounds end then they all have to go to map 1 ...


(2) Player falls in water ... dead
When a player (maybe with car) falls into the water he's dead: this don't work too:
(under InGameModeInit)
pawn Код:
new Float:x, Float:y, Float:z;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      GetPlayerPos(i, x, y, z);
      if(z < -2) //maybe the coord is wrong :S
      {
        SetPlayerHealth(i, 0.0);
      }
    }
(3) Player with highest car health wins the round ! (ERROR) [SOLVED]

pawn Код:
new Float:max = 0.00; //line 1174
        new winner = -1;
        for(new i = 0; i < GetMaxPlayers(); i++)
        {
          if(IsPlayerConnected(i))
         {
              if(IsPlayerInAnyVehicle(i))
              {
                new Float:h;
                GetVehicleHealth(GetPlayerVehicleID(i),h);
                if(h > max)
                {
                  max = h;
                  winner = i;
                 }
               }


          }
        }
        if(winner != -1)
        {
          new name[MAX_PLAYER_NAME], string[80]; //line 1196
          GetPlayerName(winner,name,sizeof(name));
          format(string,sizeof(string),"%s's vehicle has the most health and won this round",name);
          SendClientMessageToAll(COLOR_WHITE,string);//or whatever color you need
        }
THE ERRORS:
Код:
C:\Users\Michael\Desktop\GTA\Eigen server\gamemodes\derby1.pwn(1174) : warning 219: local variable "max" shadows a variable at a preceding level
C:\Users\Michael\Desktop\GTA\Eigen server\gamemodes\derby1.pwn(1196) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
(4) If round is in progress, the spawned player has to spectate
BTW this don't work too :S

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == DERBYMEMBER)
    {
        if(EndRoundCounter != 0)
        {
            SetPlayerPos(playerid, 1377.2653,2209.4810,17.6797);
            SendClientMessage(playerid, COLOR_RED,"Sorry, you can't join while the round is in progress, you have to wait ...");
            SendClientMessage(playerid, COLOR_ORANGE,"While you have to wait, you can specate the ADMIN !");
            GameTextForPlayer(playerid, "~y~Round in progress ...", 1250, 3);
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectatePlayer(playerid, 0);
        }
    }
    return 1;
}
If the round is in progress the ppl has to see someone/the admin. I want random spectate ... idk how to do that.
With this script the player don't see the ppl who plays, you can only see random place in SA
I hope someone can help (a)
Reply
#2

The first thing

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
        new OtherSpawn = random(3);
        switch (OtherSpawn)
        {
            case 0:
            {
                SetPlayerPos(i, 1369.2378,2195.9094,9.7578);
                TogglePlayerSpectating(i, 0);
            }
            case 1:
            {
                SetPlayerPos(i,2897.8269,529.6500,2.5237);
                TogglePlayerSpectating(i, 0);
            }
            case 2:
            {
                SetPlayerPos(i, -1164.3026,-927.6463,129.2188);
                TogglePlayerSpectating(i, 0);
            }
        }
}
Reply
#3

Quote:
Originally Posted by Medal Of Honor team
Посмотреть сообщение
The first thing

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
        new OtherSpawn = random(3);
        switch (OtherSpawn)
        {
            case 0:
            {
                SetPlayerPos(i, 1369.2378,2195.9094,9.7578);
                TogglePlayerSpectating(i, 0);
            }
            case 1:
            {
                SetPlayerPos(i,2897.8269,529.6500,2.5237);
                TogglePlayerSpectating(i, 0);
            }
            case 2:
            {
                SetPlayerPos(i, -1164.3026,-927.6463,129.2188);
                TogglePlayerSpectating(i, 0);
            }
        }
}
ow yeah ! it works ! ;p TYSM
Reply
#4

Anyone ??
Reply
#5

(I bumped after 2 days ... or not ?)

Does anyone know the z positions for if someones is in the water ?? [PROBLEM 2]

Does anyone know how to spectate a random player if the round is in progress ?? [PROBLEM 4]
Reply
#6

Well it ain't a "Z" for all water, i don't know if you know but SA's terrain ain't flat..its something like the globe..
In some places the water is upper then some other places..At least the terrain is.
Reply
#7

Water level is same everywhere, isn't it? Just /save position while in the sea and there you have Z, I think.
Reply
#8

Quote:
Originally Posted by AlExAlExAlEx
Посмотреть сообщение
Well it ain't a "Z" for all water, i don't know if you know but SA's terrain ain't flat..its something like the globe..
In some places the water is upper then some other places..At least the terrain is.
It is ? I haved saved ingame around Las Venturas and the z pos was -0, 2423 or something so it is around 0. But when i do that it doesnt work when someone falls in the water ..;

Quote:
Originally Posted by -/!\-
Посмотреть сообщение
Water level is same everywhere, isn't it? Just /save position while in the sea and there you have Z, I think.
Yeah, i though that too ! Normally the water is all around 0, z position.

>> But maybe i have added wrong ... i have added under OnGameModeInit ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)