Goto Command.
#1

Hello Sa-Mp again, I have a concerning about how to teleport myself in player's car if he is in a vehicle with cmd /goto
here is my command I tried to put PutPlayerInVehicle but I spoiled it.. sorry for giving you problems with my stupid commands
Here is my command GOTO.
Код:
CMD:goto(playerid, params[])
{
	if(playerVariables[playerid][pAdminLevel] >= 1)
	{
	    new userID;
	    new vehicleid = GetPlayerVehicleID(userID);
		if(sscanf(params, "u", userID)) {
		 return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/goto [playerid]");
		}
		else {
		    if(!IsPlayerConnected(userID)) return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");
		    new messageString[64];
		    new Float: fPos[3];
		    GetPlayerPos(userID, fPos[0], fPos[1], fPos[2]);
		    if(IsPlayerInAnyVehicle(userID) && GetPlayerState(userID) == PLAYER_STATE_DRIVER)
		    {
				LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(userID));
				SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(userID));
		 		PutPlayerInVehicle(playerid, vehicleid, 1);
		 		SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
		    }
			else
			{
			    SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
			    SetVehiclePos(GetPlayerVehicleID(playerid), fPos[0], fPos[1]+2, fPos[2]);
			}
   			SetPlayerInterior(playerid, GetPlayerInterior(userID));
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(userID));
   			GetPlayerName(userID, szPlayerName, MAX_PLAYER_NAME);
			format(messageString, sizeof(messageString), "You have teleported to %s.", szPlayerName);
			SendClientMessage(playerid, COLOR_WHITE, messageString);
			IsOnDM[playerid] = IsOnDM[userID];
			InBizz[playerid] = InBizz[userID];
			InHouse[playerid] = InHouse[userID];
			InHQ[playerid] = InHQ[userID];
		}
	}
	return 1;
}
Thank you very much bros
Reply
#2

You are using PLAYERID and not USERID
Reply
#3

I mean if he is connected not disconnected for example he is driving so when I use /goto [playerid] should teleport me inside his car which is he using at the moment.
Reply
#4

@Command edited

Код:
CMD:goto(playerid, params[])
{
	if(playerVariables[playerid][pAdminLevel] >= 1)
	{
	    new userID;
		if(sscanf(params, "u", userID)) {
		 return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/goto [playerid]");
		}
		else {
		    if(!IsPlayerConnected(userID)) return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");
		    new messageString[64];
		    new Float: fPos[3];
		    GetPlayerPos(userID, fPos[0], fPos[1], fPos[2]);
		    if(IsPlayerInAnyVehicle(userID) && GetPlayerState(userID) == PLAYER_STATE_DRIVER)
		    {
                                new vehicleid = GetPlayerVehicleID(userID);
				LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(userID));
				SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(userID));
		 		PutPlayerInVehicle(playerid, vehicleid, 1);
		 		SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
		    }
			else
			{
			    SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
			    SetVehiclePos(GetPlayerVehicleID(playerid), fPos[0], fPos[1]+2, fPos[2]);
			}
   			SetPlayerInterior(playerid, GetPlayerInterior(userID));
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(userID));
   			GetPlayerName(userID, szPlayerName, MAX_PLAYER_NAME);
			format(messageString, sizeof(messageString), "You have teleported to %s.", szPlayerName);
			SendClientMessage(playerid, COLOR_WHITE, messageString);
			IsOnDM[playerid] = IsOnDM[userID];
			InBizz[playerid] = InBizz[userID];
			InHouse[playerid] = InHouse[userID];
			InHQ[playerid] = InHQ[userID];
		}
	}
	return 1;
}
Reply
#5

You have to check a empty seat before to place the player on it. So.. use it:

Код HTML:
CMD:goto(playerid, params[])
{
	if(playerVariables[playerid][pAdminLevel] >= 1)
	{
	    new userID;
	    new vehicleid = GetPlayerVehicleID(userID);
		if(sscanf(params, "u", userID)) {
		 return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/goto [playerid]");
		}
		else {
		    if(!IsPlayerConnected(userID)) return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");
		    new messageString[64];
		    new Float: fPos[3];
		    GetPlayerPos(userID, fPos[0], fPos[1], fPos[2]);
		    if(IsPlayerInAnyVehicle(userID) && GetPlayerState(userID) == PLAYER_STATE_DRIVER)
		    {
				LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(userID));
				SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(userID));
		 		PutPlayerInVehicle(playerid, vehicleid, 1);
		 		SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
		    }
		    else if(IsPlayerInAnyVehicle(userID) && getEmptySeat(GetPlayerVehicleID(userID))>-1){
				PutPlayerInVehicle(playerid, GetPlayerVehicleID(userID), getEmptySeat(GetPlayerVehicleID(userID)));
				}
			else
			{
			    SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
			    SetVehiclePos(GetPlayerVehicleID(playerid), fPos[0], fPos[1]+2, fPos[2]);
			}
   			SetPlayerInterior(playerid, GetPlayerInterior(userID));
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(userID));
   			GetPlayerName(userID, szPlayerName, MAX_PLAYER_NAME);
			format(messageString, sizeof(messageString), "You have teleported to %s.", szPlayerName);
			SendClientMessage(playerid, COLOR_WHITE, messageString);
			IsOnDM[playerid] = IsOnDM[userID];
			InBizz[playerid] = InBizz[userID];
			InHouse[playerid] = InHouse[userID];
			InHQ[playerid] = InHQ[userID];
		}
	}
	return 1;
}
Add:

Код HTML:
stock getEmptySeat(vehicleid) {
	new i, free;
	for(i=0; i<GetMaxSeats(vehicleid); i++){
		free = i;
		foreach(Player, x) {
			if(GetPlayerVehicleID(x) == vehicleid && GetPlayerVehicleSeat(x) == i) free = -1;
		}
		if(free!=-1) return i;
	}
	return -1;
}
stock GetMaxSeats(vehicleid){
    return MaxSeats[(GetVehicleModel(vehicleid) - 400)];
}

stock checkVehicleSeat(vehicleid, seatid) {
	foreach(Player, x) {
	    if(GetPlayerVehicleID(x) == vehicleid && GetPlayerVehicleSeat(x) == seatid) return 1;
	}
	return 0;
}

new MaxSeats[212] = {
4,2,2,2,4,4,1,2,2,4,2,2,2,4,2,2,4,2,4,2,4,4,2,2,2,1,4,4,4,2,1,9,1,2,2,1,2,9,4,2,
4,1,2,2,2,4,1,2,1,6,1,2,1,1,1,2,2,2,4,4,2,2,2,2,2,2,4,4,2,2,4,2,1,1,2,2,1,2,2,4,
2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,4,2,2,2,2,2,2,2,2,4,2,1,1,2,1,1,2,2,4,2,2,1,
1,2,2,2,2,2,2,2,2,4,1,1,1,2,2,2,2,0,0,1,4,2,2,2,2,2,4,4,2,2,4,4,2,1,2,2,2,2,2,2,
4,4,2,2,1,2,4,4,1,0,0,1,1,2,1,2,2,2,2,4,4,2,4,1,1,4,2,2,2,2,6,1,2,2,2,1,4,4,4,2,
2,2,2,2,4,2,1,1,1,4,1,1
};
Reply
#6

So you want make when Driver teleport with him Vehicle .. he move with him vehicle and he be a DRIVER again ?
Reply
#7

Quote:
Originally Posted by Nin9r
Посмотреть сообщение
Add:
You missed
Код:
new MaxSeats[] = {
4,2,2,2,4,4,1,2,2,4,2,2,2,4,2,2,4,2,4,2,4,4,2,2,2,1,4,4,4,2,1,500,1,2,2,0,2,500,4,2,4,1,2,2,2,4,1,2,
1,0,0,2,1,1,1,2,2,2,4,4,2,2,2,2,1,1,4,4,2,2,4,2,1,1,2,2,1,2,2,4,2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,
4,2,2,1,2,2,2,2,2,4,2,1,1,2,1,1,2,2,4,2,2,1,1,2,2,2,2,2,2,2,2,4,1,1,1,2,2,2,2,500,500,1,4,2,2,2,2,2,
4,4,2,2,4,4,2,1,2,2,2,2,2,2,4,4,2,2,1,2,4,4,1,0,0,1,1,2,1,2,2,1,2,4,4,2,4,1,0,4,2,2,2,2,0,0,500,2,2,
1,4,4,4,2,2,2,2,2,4,2,0,0,0,4,0,0};
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You missed
Код:
new MaxSeats[] = {
4,2,2,2,4,4,1,2,2,4,2,2,2,4,2,2,4,2,4,2,4,4,2,2,2,1,4,4,4,2,1,500,1,2,2,0,2,500,4,2,4,1,2,2,2,4,1,2,
1,0,0,2,1,1,1,2,2,2,4,4,2,2,2,2,1,1,4,4,2,2,4,2,1,1,2,2,1,2,2,4,2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,
4,2,2,1,2,2,2,2,2,4,2,1,1,2,1,1,2,2,4,2,2,1,1,2,2,2,2,2,2,2,2,4,1,1,1,2,2,2,2,500,500,1,4,2,2,2,2,2,
4,4,2,2,4,4,2,1,2,2,2,2,2,2,4,4,2,2,1,2,4,4,1,0,0,1,1,2,1,2,2,1,2,4,4,2,4,1,0,4,2,2,2,2,0,0,500,2,2,
1,4,4,4,2,2,2,2,2,4,2,0,0,0,4,0,0};
true :P
Reply
#9

Just a second I'm testing it, Thx brothers for reply

EDIT: I get this error: error 017: undefined symbol "MaxSeats"
Reply
#10

Quote:
Originally Posted by Digii
Посмотреть сообщение
Just a second I'm testing it, Thx brothers for reply

EDIT: I get this error: error 017: undefined symbol "MaxSeats"
Код:
new MaxSeats[] = {
4,2,2,2,4,4,1,2,2,4,2,2,2,4,2,2,4,2,4,2,4,4,2,2,2,1,4,4,4,2,1,500,1,2,2,0,2,500,4,2,4,1,2,2,2,4,1,2,
1,0,0,2,1,1,1,2,2,2,4,4,2,2,2,2,1,1,4,4,2,2,4,2,1,1,2,2,1,2,2,4,2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,
4,2,2,1,2,2,2,2,2,4,2,1,1,2,1,1,2,2,4,2,2,1,1,2,2,2,2,2,2,2,2,4,1,1,1,2,2,2,2,500,500,1,4,2,2,2,2,2,
4,4,2,2,4,4,2,1,2,2,2,2,2,2,4,4,2,2,1,2,4,4,1,0,0,1,1,2,1,2,2,1,2,4,4,2,4,1,0,4,2,2,2,2,0,0,500,2,2,
1,4,4,4,2,2,2,2,2,4,2,0,0,0,4,0,0};
Put that at the top of your code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)