[Solved]
#1

Код:
if(strcmp(cmdtext, "/lowrider", true) == 0) {
ResetPlayerWeapons(playerid);
SetPlayerPos(playerid,2645.40, -2004.71, 13.38);
GivePlayerMoney(playerid, 50000);
return 1;
}
So, if a player is in a car, he still teleports on foot. what's the problem?
Reply
#2

Use IsPlayerInAnyVehicle check and use SetVehiclePos.
Reply
#3

Ok, will try it. I post back when it either works or doesn't work.
Reply
#4

Still not works :/
Код:
if(strcmp(cmdtext, "/lowrider", true) == 0) {
new vehicleid;
ResetPlayerWeapons(playerid);
IsPlayerInAnyVehicle(playerid);
SetVehiclePos(vehicleid, 2645.40, -2004.71, 13.38);
SetPlayerPos(playerid,2645.40, -2004.71, 13.38);
GivePlayerMoney(playerid, 50000);
return 1;
}
Can somebody please help? it still not worked.
Reply
#5

pawn Код:
if(strcmp(cmdtext, "/lowrider", true) == 0)
{
ResetPlayerWeapons(playerid);
if(IsPlayerInAnyVehicle(playerid)) SetVehiclePos(GetPlayerVehicleID(playerid), 2645.40, -2004.71, 13.38);
else SetPlayerPos(playerid, 2645.40, -2004.71, 13.38);
GivePlayerMoney(playerid, 50000);
return 1;
}
Reply
#6

zOMFG Thanks!!! Nice man.

EDIT: You can also teleport without car. how to prevent that?
Reply
#7

Quote:
Originally Posted by speedruntrainer
zOMFG Thanks!!! Nice man.

EDIT: You can also teleport without car. how to prevent that?
Without car just do SetPlayerPos(playerid,Float,Float:y,Float:z);
With that your player will be teleported to x,y,z .Without any other vehicle.


Ecko
Reply
#8

Eh I mean, If the player IS NOT in a vehicle, he can't teleport. "You must be in a vehicle to use this command" That's what I'm trying to tell you. >.<

pawn Код:
if(strcmp(cmdtext, "/lowrider", true) == 0) {
ResetPlayerWeapons(playerid);
if(IsPlayerInAnyVehicle(playerid)) SetVehiclePos(GetPlayerVehicleID(playerid), 2645.40, -2004.71, 13.38);
else SetPlayerPos(playerid, 2645.40, -2004.71, 13.38);
GivePlayerMoney(playerid, 50000);
return 1;
}
Reply
#9

Quote:
Originally Posted by Don Correlli
pawn Код:
if(strcmp(cmdtext, "/lowrider", true) == 0)
{
ResetPlayerWeapons(playerid);
if(IsPlayerInAnyVehicle(playerid)) SetVehiclePos(GetPlayerVehicleID(playerid), 2645.40, -2004.71, 13.38);
else SetPlayerPos(playerid, 2645.40, -2004.71, 13.38);
GivePlayerMoney(playerid, 50000);
return 1;
}
As you can see, if he is any vehicle then player and vehicle will be teleported (SetVehiclePos), if not then only player will be teleported (SetPlayerPos).

If you want to prevent teleporting on foot, change:
pawn Код:
else SetPlayerPos(playerid, 2645.40, -2004.71, 13.38);
to:
pawn Код:
else SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: You can't teleport if you're not in vehicle!");
You maybe want to add PLAYER_STATE_DRIVER check so only driver of the vehicle can teleport it.
Reply
#10

pawn Код:
if(strcmp(cmdtext, "/lowrider", true) == 0)
{
ResetPlayerWeapons(playerid);
if(IsPlayerInAnyVehicle(playerid)) SetVehiclePos(GetPlayerVehicleID(playerid), 2645.40, -2004.71, 13.38);
else SendClientMessage(playerid, 0x0000BBAA , " You can do this only if you are in an vehicle");
GivePlayerMoney(playerid, 50000);
return 1;
}
Does this work ?

Don Correlli it seems that you edited in the same time with my post .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)