Teleport time -
bleedis - 07.01.2012
Hellou!
Someone can help me with teleport thing? Like - when i type /sf it teleports me to San fierro but only when i type /sf i have to wait 5 sec and only then i get to sf.
Код:
if(strcmp(cmdtext, "/sf", true) == 0)
{new cartype = GetPlayerVehicleID(playerid);
new State=GetPlayerState(playerid);
SetPlayerInterior(playerid,0);
{if(State!=PLAYER_STATE_DRIVER)
{SetPlayerPos(playerid,-1972.6483,283.9722,35.1719);}
else if(IsPlayerInVehicle(playerid, cartype) == 1)
{SetVehiclePos(cartype,-1972.6483,283.9722,35.1719);
SetVehicleZAngle(cartype,184.6754);}
else
{SetPlayerPos(playerid,-1972.6483,283.9722,35.1719);}
GameTextForPlayer(playerid,"~g~San Fierro",2500,1);}
return 1;}
Thanks!. I hope you understand what i want. not my day..
Re: Teleport time -
BlackWolf120 - 07.01.2012
pawn Код:
if(strcmp(cmdtext, "/sf", true) == 0)
{
SetTimerEx("SFtele",5000,false,"i",playerid);
GameTextForPlayer(playerid,"~g~Please wait 5 seconds...",2500,1);
return 1;
}
forward SFtele(playerid);
public SFtele(playerid)
{
new cartype = GetPlayerVehicleID(playerid);
new State=GetPlayerState(playerid);
SetPlayerInterior(playerid,0);
if(State!=PLAYER_STATE_DRIVER)
{
SetPlayerPos(playerid,-1972.6483,283.9722,35.1719);
}
else if(IsPlayerInVehicle(playerid, cartype) == 1)
{
SetVehiclePos(cartype,-1972.6483,283.9722,35.1719);
SetVehicleZAngle(cartype,184.6754);
}
else
{
SetPlayerPos(playerid,-1972.6483,283.9722,35.1719);
}
GameTextForPlayer(playerid,"~g~San Fierro",2500,1);
return 1;
}
Re: Teleport time -
Psymetrix - 07.01.2012
Use a timer and a public function.
This compiles but is not tested.
pawn Код:
new bool:g_IsPlayerTeleporting[ MAX_PLAYERS char ];
TeleportPlayer( playerid, Float:x, Float:y, Float:z, Float:a, interior, world )
{
if( g_IsPlayerTeleporting{ playerid } == false )
{
SetTimerEx( "TeleportPlayer", 5000, false, "ifffii", playerid, x, y, z, a, interior, world );
g_IsPlayerTeleporting{ playerid } = true;
}
}
forward _TeleportPlayer( playerid, Float:x, Float:y, Float:z, Float:a, interior, world );
public _TeleportPlayer( playerid, Float:x, Float:y, Float:z, Float:a, interior, world )
{
if ( IsPlayerConnected( playerid ) )
{
if ( GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
new vehicleid = GetPlayerVehicleID( playerid );
SetVehiclePos( vehicleid, x, y, z );
SetVehicleZAngle( vehicleid, a );
LinkVehicleToInterior( vehicleid, interior );
SetVehicleVirtualWorld( vehicleid, world );
}
else
{
SetPlayerPos( playerid, x, y, z );
SetPlayerFacingAngle( playerid, a );
}
SetPlayerInterior( playerid, interior );
SetPlayerVirtualWorld( playerid, world );
SetCameraBehindPlayer( playerid );
}
g_IsPlayerTeleporting{ playerid } = false;
}
To use;
pawn Код:
if(strcmp(cmdtext, "/sf", true) == 0)
{
TeleportPlayer( playerid, -1972.6483, 283.9722, 35.1719, 184.6754, 0, 0 );
return 1;
}
I know I shouldn't just give you the code so please read it over and learn how it works. If you don't know already that is
Re: Teleport time -
bleedis - 07.01.2012
Thanks.
Both of you!