10.10.2012, 18:42
(
Последний раз редактировалось BlueGames; 11.10.2012 в 10:39.
)
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.
- How to add TP from place to another place via " C " "KEY_CROUCH".
- now add this line into " OnPlayerKeyStateChange " - if(newkeys & KEY_CROUCH) <<-- This line is tagged your tping via " C"
- Ok, now we need set position so player will be around it and " C " then tping.
- Done.
- Alright, We back to " OnPlayerKeyStateChange " and adding new line.
Also, Fire plus " C " button.
- Done.
- Alright, Again go to " OnPlayerKeyStateChange ", Add this lines
- 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 ".
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 !
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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);
}
Also you can watch here for more buttons are able IG Wiki SAMP - GetPlayerKeys.
Good Luck !