Creating Teleporting with other buttons ! -
BlueGames - 10.10.2012
Hi,
I'll explain how to make teleporting with few buttons.
All you keys / buttons must be default, That cannot works with random buttons
Lets start:
- Open your GameMode / Filterscript.
Now place this lines around some place into your GameMode.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
- How to add TP from place to another place via " C " "KEY_CROUCH".
Teleporting with " C " / " Crouch " button
- now add this line into " OnPlayerKeyStateChange " - if(newkeys & KEY_CROUCH) <<-- This line is tagged your tping via " C"
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_CROUCH)
{
}
return 1;
}
- Ok, now we need set position so player will be around it and " C " then tping.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_CROUCH)
{
if(IsPlayerInSphere(playerid,0.0 ,0.0 , 0.0 ,1)) // <<<------- Player is around X,Y,Z
{
SetPlayerPos(playerid,0.0 ,0.0 , 0.0);// <<<-------- Player is teleporting to new position.
return 1;
}
}
return 1;
}
- Done.
Teleporting with FIRE button
- Alright, We back to " OnPlayerKeyStateChange " and adding new line.
pawn Код:
if(newkeys & KEY_FIRE)
{
if(IsPlayerInSphere(playerid,0.0 ,0.0 , 0.0 ,1)) // <<<------- Player is around X,Y,Z
{
SetPlayerPos(playerid,0.0 ,0.0 , 0.0);// <<<-------- Player is teleporting to new position.
return 1;
}
}
Also, Fire plus " C " button.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_CROUCH)
{
if(IsPlayerInSphere(playerid,0.0 ,0.0 , 0.0 ,1)) // <<<------- Player is around X,Y,Z
{
SetPlayerPos(playerid,0.0 ,0.0 , 0.0);// <<<-------- Player is teleporting to new position.
return 1;
}
}
if(newkeys & KEY_FIRE)
{
if(IsPlayerInSphere(playerid,0.0 ,0.0 , 0.0 ,1)) // <<<------- Player is around X,Y,Z
{
SetPlayerPos(playerid,0.0 ,0.0 , 0.0);// <<<-------- Player is teleporting to new position.
return 1;
}
}
return 1;
}
- Done.
Teleporting with " Y " / " N " buttons
- Alright, Again go to " OnPlayerKeyStateChange ", Add this lines
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_YES)
{
if(IsPlayerInSphere(playerid,0.0 ,0.0 , 0.0 ,1)) // <<<------- Player is around X,Y,Z
{
SetPlayerPos(playerid,0.0 ,0.0 , 0.0);// <<<-------- Player is teleporting to new position.
return 1;
}
}
if(newkeys & KEY_NO)
{
if(IsPlayerInSphere(playerid,0.0 ,0.0 , 0.0 ,1)) // <<<------- Player is around X,Y,Z
{
SetPlayerPos(playerid,0.0 ,0.0 , 0.0);// <<<-------- Player is teleporting to new position.
return 1;
}
}
return 1;
}
- Done.
EDIT:
" IsPlayerInSphere " - Creating a positon so if player is around it he can force a cmd, teleport etc'.
Like if you want make some position is just there the cmd will be allowd and not everywhere on map.
You just mark a position and just if you around it you can do what you made.
defined the " IsPlayerInSphere ".
pawn Код:
stock IsPlayerInSphere(playerid,Float:sx,Float:sy,Float:sz,sradius)
{
if(GetPlayerDistanceToPointEx(playerid,sx,sy,sz) < sradius)
{
return 1;
}
return 0;
}
stock GetPlayerDistanceToPointEx(playerid,Float:sx,Float:sy,Float:sz)
{
new Float:x1,Float:y1,Float:z1;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(sx,x1)),2)+floatpower(floatabs(floatsub(sy,y1)),2)+floatpower(floatabs(floatsub(sz,z1)),2));
return floatround(tmpdis);
}
Any help about teleporting with other buttons you can getvia /PM me.
Also you can watch here for more buttons are able IG
Wiki SAMP - GetPlayerKeys.
Good Luck !
Re: Creating Teleporting with other buttons ! -
Ghost_Boii - 10.10.2012
Nice
Re: Creating Teleporting with other buttons ! -
BlueGames - 10.10.2012
Quote:
Originally Posted by Ghost_Boii
Nice
|
Thank you !
Re: Creating Teleporting with other buttons ! -
Luis- - 10.10.2012
You haven't included this function 'IsPlayerInSphere'.
Re: Creating Teleporting with other buttons ! -
Vince - 10.10.2012
Add this, add this, add this. Nothing explained whatsoever. Wiki does it better. Sorry.
Re: Creating Teleporting with other buttons ! -
BlueGames - 10.10.2012
Quote:
Originally Posted by -Luis
You haven't included this function 'IsPlayerInSphere'.
|
Thank you, just forget cuz i was hurry to do something.
Anyway its added.
Quote:
Originally Posted by Vince
Add this, add this, add this. Nothing explained whatsoever. Wiki does it better. Sorry.
|
As you see that, Pepole can see this tutorial as usefully.
Sorry im not einstein.
Re: Creating Teleporting with other buttons ! - Glint - 11.10.2012
Quote:
Originally Posted by BlueGames
As you see that, Pepole can see this tutorial as usefully.
Sorry im not einstein.
|
You don't have to be Einstein in order to write a good tutorial, it is not difficult.
I agree with Vince sorry.
Re: Creating Teleporting with other buttons ! -
BlueGames - 11.10.2012
Quote:
Originally Posted by Glint
You don't have to be Einstein in order to write a good tutorial, it is not difficult.
I agree with Vince sorry.
|
So why you both replay here if you dont think that is helpfully, You was can ignore that thread and thats all.
I dont see more things are need explain, it is just the basic of this "system", that why i said more help via PMs.
I explained how to make simple and shurt tping with buttons.
Re: Creating Teleporting with other buttons ! - Jarnu - 11.10.2012
Never heared about this one O.o
Re: Creating Teleporting with other buttons ! - Glint - 11.10.2012
Quote:
Originally Posted by BlueGames
So why you both replay here if you dont think that is helpfully, You was can ignore that thread and thats all.
I dont see more things are need explain, it is just the basic of this "system", that why i said more help via PMs.
I explained how to make simple and shurt tping with buttons.
|
Explain what this :
Код:
tmpdis = floatsqroot(floatpower(floatabs(floatsub(sx,x1)),2)+floatpower(floatabs(floatsub(sy,y1)),2)+floatpower(floatabs(floatsub(sz,z1)),2));
Does.
A tutorial should explain everything don't tell me things like "this is easy" or "everyone should know this"
Just explain it.