[Tutorial] Creating Teleporting with other buttons !
#1

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 !
Reply
#2

Nice
Reply
#3

Quote:
Originally Posted by Ghost_Boii
Посмотреть сообщение
Nice
Thank you !
Reply
#4

You haven't included this function 'IsPlayerInSphere'.
Reply
#5

Add this, add this, add this. Nothing explained whatsoever. Wiki does it better. Sorry.
Reply
#6

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.
Reply
#7

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.
Reply
#8

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.
Reply
#9

Код:
IsPlayerInSphere
Never heared about this one O.o
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)