How to do this? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to do this? (
/showthread.php?tid=424632)
How to do this? -
LeeXian99 - 23.03.2013
Hello guys, today I created a teleport, just wondered how to teleport to a place with your vehicle? My script is just teleporting without cars.
pawn Код:
if (strcmp("/beach", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 309.7616,-1798.7969,4.4990);
SendClientMessage(playerid, 0x00FF00, "Welcome to Los Santo Beach");
new name[MAX_PLAYER_NAME+1], string[128];
GetPlayerName(playerid, name, sizeof(name));
format (string, sizeof(string), "[TP]: %s has teleported to /beach.", name);
SendClientMessageToAll (0x0000BBAA, string);
return 1;
}
I need some pros to teach me.
Re: How to do this? -
Glad2BeHere - 23.03.2013
pawn Код:
if (strcmp("/beach", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 309.7616,-1798.7969,4.4990);
SendClientMessage(playerid, 0x00FF00, "Welcome to Los Santo Beach");
new name[MAX_PLAYER_NAME+1], string[128];
GetPlayerName(playerid, name, sizeof(name));
format (string, sizeof(string), "[TP]: %s has teleported to /beach.", name);
SendClientMessageToAll (0x0000BBAA, string);
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
v = GetPlayerVehicleID(playerid);
SetVehiclePos(v, 309.7616,-1798.7969,4.4990);
PutPlayerInVehicle(playerid, v, 0);
}
return 1;
}
// if its the drive :D
Re: How to do this? -
greentarch - 23.03.2013
Explained at the comments.
pawn Код:
if (strcmp("/beach", cmdtext, true, 10) == 0)
{
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // The player is a driver of a vehicle!
{
new iVeh = GetPlayerVehicleID(playerid); // Get's the player's current vehicle ID.
SetVehiclePos(iVeh, 309.7616, -1798.7969, 4.4990); // Set's the vehicle's position.
}
else // The player is not a driver of a vehicle!
{
SetPlayerPos(playerid, 309.7616, -1798.7969, 4.4990); // Set's the player's current position
}
// Sends the player a client message
SendClientMessage(playerid, 0x00FF00, "Welcome to Los Santos Beach!");
new name[MAX_PLAYER_NAME], string[128]; // Create 2 new variables.
GetPlayerName(playerid, name, sizeof(name)); // Get's the player's name.
format(string, sizeof(string), "[TP]: %s has teleported to /beach.", name); // Formats the string.
SendClientMessageToAll(0x0000BBAA, string); // Sends a message to all players
return true;
}
Re: How to do this? -
LeeXian99 - 23.03.2013
Thanks, I'll give a +1 rep to greentarch as it works for me.