SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 23/01/2010, 08:47 AM   #1
[dN]Eagle
Big Clucker
 
Join Date: Jan 2010
Posts: 79
Reputation: 0
Default My questions here. (please have a look here, this will be updated frequently)

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
[dN]Eagle is offline  
Old 23/01/2010, 08:51 AM   #2
llama
Big Clucker
 
Join Date: Dec 2007
Posts: 109
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

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

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.
llama is offline  
Old 23/01/2010, 08:53 AM   #3
[dN]Eagle
Big Clucker
 
Join Date: Jan 2010
Posts: 79
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

I am going to try it, thanks!


EDIT: It works, thanks very much
[dN]Eagle is offline  
Old 23/01/2010, 09:00 AM   #4
mansonh
Gangsta
 
Join Date: Jun 2009
Posts: 615
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

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.

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;
  }
}
__________________
mansonh is offline  
Old 23/01/2010, 09:11 AM   #5
[dN]Eagle
Big Clucker
 
Join Date: Jan 2010
Posts: 79
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

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: }
[dN]Eagle is offline  
Old 23/01/2010, 09:13 AM   #6
llama
Big Clucker
 
Join Date: Dec 2007
Posts: 109
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

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.
llama is offline  
Old 23/01/2010, 09:15 AM   #7
[dN]Eagle
Big Clucker
 
Join Date: Jan 2010
Posts: 79
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

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

Thanks for the help tho.
[dN]Eagle is offline  
Old 23/01/2010, 09:18 AM   #8
mansonh
Gangsta
 
Join Date: Jun 2009
Posts: 615
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

Oops, my bad, just coding on the fly, not actually compiling anything i am writing (not bad, only one silly error :P)
__________________
mansonh is offline  
Old 23/01/2010, 09:53 AM   #9
[dN]Eagle
Big Clucker
 
Join Date: Jan 2010
Posts: 79
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

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
[dN]Eagle is offline  
Old 23/01/2010, 09:55 AM   #10
llama
Big Clucker
 
Join Date: Dec 2007
Posts: 109
Reputation: 0
Default Re: Kill players when they are lower then "Z.Z"

What is your OnPlayerSpawn and your OnPlayerRequestSpawn?
llama is offline  
 

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
Frequently Asked Questions [READ THIS BEFORE POSTING] Woet Server Support 87 21/06/2018 01:56 PM
SA-MP Frequently Asked Questions JaTochNietDan General 166 08/10/2012 10:08 PM
gta crashing frequently w/ error report and minimizing my desktop resolution Micro99 Client Support 1 25/04/2009 05:12 PM


All times are GMT. The time now is 12:44 AM.


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