Teleport-Car wont come
#1

I just made my own first teleport! I was werry happy with it until i found out cars is at the same position as when i typed the cmd. Here are the scripts

cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/nascar", true) == 0)
{
SetPlayerPos(playerid,1433.4521,1504.1399,10.8203) ;
return 1;
}
if(strcmp(cmd, "/sf", true) == 0)
{
SetPlayerPos(playerid,-1898.6420,243.1353,41.0469);
return 1;
Reply
#2

Can you please elaborate? It would help alot.
Reply
#3

elaborate? :P sry for bad english
Reply
#4

That means you need to explain more about your situation.
Anyway I guess you meant the car isn't teleporting with the player, am I right?

Try this:
pawn Код:
new Vehicle;
if(strcmp(cmd,"/nascar", true) == 0)
{
    SetPlayerPos(playerid,1433.4521,1504.1399,10.8203);
    if(IsPlayerInAnyVehicle(playerid)) {
    Vehicle = GetPlayerVehicleID(playerid); SetVehiclePos(Vehicle,1433.4521,1504.1399,10.8203);
    PutPlayerInVehicle(Vehicle); }
    return 1;
}

if(strcmp(cmd,"/sf", true) == 0)
{
    SetPlayerPos(playerid,-1898.6420,243.1353,41.0469);
    if(IsPlayerInAnyVehicle(playerid)) {
    Vehicle = GetPlayerVehicleID(playerid); SetVehiclePos(Vehicle,-1898.6420,243.1353,41.0469);
    PutPlayerInVehicle(Vehicle); }
    return 1;
}
Reply
#5

https://sampwiki.blast.hk/wiki/GetPlayerState
https://sampwiki.blast.hk/wiki/GetPlayerVehicleID
https://sampwiki.blast.hk/wiki/SetVehiclePos

[XST]O_x, your example isn't great. Here's a better solution:

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetPlayerPos(playerid, x, y, z);
else SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
Reply
#6

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
That means you need to explain more about your situation.
Anyway I guess you meant the car isn't teleporting with the player, am I right?

Try this:
pawn Код:
new Vehicle;
if(strcmp(cmd,"/nascar", true) == 0)
{
    SetPlayerPos(playerid,1433.4521,1504.1399,10.8203);
    if(IsPlayerInAnyVehicle(playerid)) {
    Vehicle = GetPlayerVehicleID(playerid); SetVehiclePos(Vehicle,1433.4521,1504.1399,10.8203);
    PutPlayerInVehicle(Vehicle); }
    return 1;
}

if(strcmp(cmd,"/sf", true) == 0)
{
    SetPlayerPos(playerid,-1898.6420,243.1353,41.0469);
    if(IsPlayerInAnyVehicle(playerid)) {
    Vehicle = GetPlayerVehicleID(playerid); SetVehiclePos(Vehicle,-1898.6420,243.1353,41.0469);
    PutPlayerInVehicle(Vehicle); }
    return 1;
}
Yes you are right. Thanks, i will try this I appriciate your help
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/GetPlayerState
https://sampwiki.blast.hk/wiki/GetPlayerVehicleID
https://sampwiki.blast.hk/wiki/SetVehiclePos

[XST]O_x, your example isn't great. Here's a better solution:

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetPlayerPos(playerid, x, y, z);
else SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
My example isn't great indeed, but your example will send the player to X Y Z if he's a driver, else, it will send the vehicle to X Y Z.
Reply
#8

Yeah, that one will work thanks btw! im his accociate ^^,
Reply
#9

Okay so I messed the order up :/

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
else SetPlayerPos(playerid, x, y, z);
The reason I use GetPlayerState instead of IsPlayerInAnyVehicle is because passengers shouldn't have control over a vehicle's teleports - only the driver should.
Reply
#10

Quote:
Originally Posted by MP2
Посмотреть сообщение
Okay so I messed the order up :/

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
else SetPlayerPos(playerid, x, y, z);
The reason I use GetPlayerState instead of IsPlayerInAnyVehicle is because passengers shouldn't have control over a vehicle's teleports - only the driver should.
I haven't been using teleportations for very long time now, so tell me, will SetVehiclePos set both vehicle and player's position to X Y Z?
Because if so, 60% of my code was indeed useless.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)