My questions here. (please have a look here, this will be updated frequently)
#1

Alright, I can't figure out how to do it myself and I can't be bothered to use search function as I used ****** and nothing good came up.


I want to kill players who come below the Z.Z coordinate, in this case it is 70.0

Someone please help me
Reply
#2

There are many ways in which you can do something like this, one example is:

pawn Code:
public OnPlayerUpdate(playerid)
{
  new Float:x, Float:y, Float:z;
  GetPlayerPos(playerid, x, y, z);
 
  if(z < 70)
  {
    SetPlayerHealth(playerid, 0);
  }
  return 1;
}
I'm sure there is a better way to do this, but this is one simple solution.
Reply
#3

I am going to try it, thanks!


EDIT: It works, thanks very much
Reply
#4

As suggested there are many ways.
I wouldn't however recommend onplayerupdate, it is called A LOT, as in 20+ times per second per player (unless you want it to kill them the exact ms they reach -70, thats a strain on your server for something so small)

If you just want to kill anyone who goes below it, then use a timer, its much easier on your server, same code as llamas.

pawn Code:
public OnGameModeInit()
{
  SetTimer("TimerDepthCheck", 1000, 1); //depending how worried you are on how suddenly it kills them you can change it 1000 = 1s
}

forward TimerDepthCheck();
public TimerDepthCheck()
{
  for(new playerid=0; playerid<GetMaxPlayers(); playerid++)
  {
    if(!IsPlayerConnected(playerid)) continue;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
 
    if(z < 70)
    {
      SetPlayerHealth(playerid, 0);
    }
    return 1;
  }
}
Reply
#5

I am getting this error with yours mansonh.

Code:
myscriptnotyours.pwn(117) : warning 209: function "TimerDepthCheck" should return a value
Code:
LINE 103: public TimerDepthCheck()
{
  for(new playerid=0; playerid<GetMaxPlayers(); playerid++)
  {
    if(!IsPlayerConnected(playerid)) continue;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);

    if(z < 70)
    {
      SetPlayerHealth(playerid, 0);
    }
    return 1;
  }
LINE 117: }
Reply
#6

Quote:
Originally Posted by [dN
Eagle ]
I am getting this error with yours mansonh.

Code:
myscriptnotyours.pwn(117) : warning 209: function "TimerDepthCheck" should return a value
Add a return 1; above the last bracket }

And that's another simple solution.
Reply
#7

Lmfao, how come I didn't figured that out myself

Thanks for the help tho.
Reply
#8

Oops, my bad, just coding on the fly, not actually compiling anything i am writing (not bad, only one silly error :P)
Reply
#9

I am just going to use this topic because I have another question.

When I try to spawn it automaticly gives me the CJ skin while I chose a different class like "demolition"


P.S: You can check it out @ 77.248.87.200:7777
Reply
#10

What is your OnPlayerSpawn and your OnPlayerRequestSpawn?
Reply
#11

Code:
public OnPlayerSpawn(playerid)
{
	return 1;
}
Code:
public OnPlayerRequestSpawn(playerid)
{
	if(gTeam[playerid] == TEAM_HOBO)
	{
 		SetPlayerColor(playerid,TEAM_HOBO_COLOR);
 	}
  	else if(gTeam[playerid] == TEAM_RICH)
  	{
  		SetPlayerColor(playerid,TEAM_RICH_COLOR);
	}
	return 1;
}
Reply
#12

Nothing there that would cause that.

What are your AddPlayerClass'es?
Reply
#13

Code:
  // TEAM HOBO
  AddPlayerClass(137, 3254.3262, -1889.8865, 73.5436, 354.3818, 24, 150, 30, 1000, 8, 1); // ATTACKER
  AddPlayerClass(135, 3265.1843, -1897.1830, 75.7411, 176.1561, 34, 150, 42, 200, 24, 100); // SNIPER
  AddPlayerClass(134, 3193.9927, -1877.9962, 76.4372, 269.2565, 37, 500, 18, 10, 9, 1); // DEMOLITION
  
  // TEAM RICH
  AddPlayerClass(35, 3137.5471, -1887.6497, 72.7787, 174.3979, 24, 150, 31, 500, 8, 1); // ATTACKER
  AddPlayerClass(36, 3127.6685, -1881.5739, 74.9761, 358.3756, 34, 150, 42, 200, 24, 100); // SNIPER
  AddPlayerClass(37, 3198.9180, -1901.3778, 76.4497, 86.8948, 37, 500, 18, 10, 9, 1); // DEMOLITION
Reply
#14

That's odd, there's nothing there that I can see that would cause that.

Have you used SpawnPlayer? Any filterscripts loaded?
Reply
#15

Problem solved.

It was caused by admin skin.
Reply
#16

Another question.

I want an admin to i.e type /dfo (disablefalloff).

This will command must overrule the Z < 70 so he can go anywhere he want to.

How can I do that?


EDIT: I am using lAdmin but if I place <ladmin> on top of my script it gives me an error when I try to compile.
Reply
#17

At top:

pawn Code:
#include <IsPlayerLAdmin>
In OnGameModeInit:

pawn Code:
new Falloff[MAX_PLAYERS];
In OnPlayerConnect:

pawn Code:
Falloff[playerid] = 0;
In OnPlayerCommandText:

pawn Code:
[The command code here]
  if(IsPlayerLAdmin(playerid))
  {
   if(Falloff[playerid] == 0)
   {
     Falloff[playerid] = 1;
     SendClientMessage(playerid, Color, "You won't be killed if you fall off!");
   }
   else
   {
     Falloff[playerid] = 0;
     SendClientMessage(playerid, Color, "You will now be killed if you fall off!");
   }
   return 1;
  }
 
  else
  {
   SendClientMessage(playerid, Color, "You are not an admin!");
   return 1;
  }
Lastly, from before change the TimerDepthCheck to this:

pawn Code:
public TimerDepthCheck()
{
  for(new playerid=0; playerid<GetMaxPlayers(); playerid++)
  {
    if(!IsPlayerConnected(playerid)) continue;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
 
    if(z < 70 && Falloff[playerid] == 0)
    {
      SetPlayerHealth(playerid, 0);
    }
    return 1;
  }
}
Reply
#18

Code:
*****.pwn(3) : fatal error 100: cannot read from file: "IsPlayerLAdmin"
Reply
#19

Make sure you have the IsPlayerLAdmin include from the topic http://forum.sa-mp.com/index.php?topic=36990.0

It goes in your server\pawno\include\ folder.
Reply
#20

By ladmin I mean Lux Admin

EDIT: Are they the same?
EDIT2: I will just try that one and if it works I will use it because they look similar.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)