Goto Command Help Needed
#1

Hello!

I need a little bit help with my goto command. When I use goto and I'm in a car, then my car disappears. How to fix this

Код:
dcmd_goto(playerid, params[])
	{
	#pragma unused params
    new ID;
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, COLOR_BLUE, "USAGE: /goto [ID]");
    else if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: {FFFFFF}This player is offline or it is yourself");
    if(toggoto[ID] == 1)
    {
	new string[50], name[MAX_PLAYER_NAME];
	format(string, sizeof(string), "%s's has Disabled goto! /toggoto", GetPlayerName(playerid, name, sizeof(name)));
	GameTextForPlayer(playerid,string,2000,3);
	return 1;
	}
	else
	{
  	new Float:x, Float:y, Float:z;
	GetPlayerPos(ID, x, y, z);
	SetPlayerPos(ID, x+2, y, z);
	}
	return 1;
	}

	dcmd_toggoto(playerid, params[])
	{
	#pragma unused params
    if(IsPlayerConnected(playerid))
    {
	if(toggoto[playerid] == 1)
	{
	toggoto[playerid] = 0;
	GameTextForPlayer(playerid,"~b~You have ~g~enabled ~b~goto",2000,3);
	return 1;
	}
	else
	{
	toggoto[playerid] = 1;
	GameTextForPlayer(playerid,"~b~You have ~r~disabled ~b~goto",2000,3);
	return 1;
	}
	}
	return 1;
	}
Thank You!
Reply
#2

I suggest to you clicking on players name teleport,it don't needs to write commands.

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    new Float:p[3];
    GetPlayerPos(clickedplayerid,p[0],p[1],p[2]);
    SetPlayerPos(playerid,p[0]+2,p[1]+2,p[2]+2);
    return 1;
}
Reply
#3

It is very nice but I need to disable goto command/clicking with a command like /toggoto
Reply
#4

Try this code

pawn Код:
#include <a_samp>
#include "../include/gl_common.inc"

#define FILTERSCRIPT

#define COLOR_WHITE 0xFFFFFFFF

public OnPlayerCommandText(playerid, cmdtext[])
{
    new idx;
    new cmd[256];

    cmd = strtok(cmdtext, idx);

    if(strcmp("/tele", cmd, true) == 0)
    {
     if(IsPlayerAdmin(playerid)) {
            new tmp[256], player, Float:X, Float:Y, Float:Z, carid, seat;
            tmp = strtok(cmdtext, idx);
            player = strval(tmp);
            GetPlayerPos(player, X, Y, Z);
            if(IsPlayerInAnyVehicle(playerid)){
                carid = GetPlayerVehicleID(playerid);
                seat = GetPlayerVehicleSeat(playerid);
                SetVehiclePos(carid, X+1, Y, Z);
                PutPlayerInVehicle(playerid, carid, seat);
                return 1;
            }
            SetPlayerPos(playerid, X+1, Y, Z);
            return 1;
        }
        else{
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are not authorized to use this command.");
            return 1;
        }
    }
    if(strcmp("/get", cmd, true) == 0)
    {
     if(IsPlayerAdmin(playerid)) {
            new tmp[256], player, Float:X, Float:Y, Float:Z, carid, seat;
            tmp = strtok(cmdtext, idx);
            player = strval(tmp);
            GetPlayerPos(playerid, X, Y, Z);
            if(IsPlayerInAnyVehicle(player)){
                carid = GetPlayerVehicleID(player);
                seat = GetPlayerVehicleSeat(player);
                SetVehiclePos(carid, X+1, Y, Z);
                PutPlayerInVehicle(player, carid, seat);
                return 1;
            }
            SetPlayerPos(player, X+1, Y, Z);
            return 1;
        }
        else{
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are not authorized to use this command.");
            return 1;
        }
    }
    return 0;
}
Reply
#5

You dont understand as I see. I wanna DISABLE the goto command. I dont need new commands. I need to DISABLE it.


I am using this command in my server GM, but when I goto to a player, then my car disapears when I'm in a car.

Код:
dcmd_goto(playerid, params[])
	{
	#pragma unused params
    new ID;
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, COLOR_BLUE, "USAGE: /goto [ID]");
    else if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: {FFFFFF}This player is offline or it is yourself");
    if(toggoto[ID] == 1)
    {
	new string[50], name[MAX_PLAYER_NAME];
	format(string, sizeof(string), "%s's has Disabled goto! /toggoto", GetPlayerName(playerid, name, sizeof(name)));
	GameTextForPlayer(playerid,string,2000,3);
	return 1;
	}
	else
	{
  	new Float:x, Float:y, Float:z;
	GetPlayerPos(ID, x, y, z);
	SetPlayerPos(ID, x+2, y, z);
	}
	return 1;
	}

	dcmd_toggoto(playerid, params[])
	{
	#pragma unused params
    if(IsPlayerConnected(playerid))
    {
	if(toggoto[playerid] == 1)
	{
	toggoto[playerid] = 0;
	GameTextForPlayer(playerid,"~b~You have ~g~enabled ~b~goto",2000,3);
	return 1;
	}
	else
	{
	toggoto[playerid] = 1;
	GameTextForPlayer(playerid,"~b~You have ~r~disabled ~b~goto",2000,3);
	return 1;
	}
	}
	return 1;
	}
Reply
#6

Just delete that command and problem is fixed.I do like this when i don't need cmd
Reply
#7

Check my post again, I updated it.
Reply
#8

Just check if playerid is driver with
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
then use SetVehiclePos function, else SetPlayerPos
Reply
#9

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Just check if playerid is driver with
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
then use SetVehiclePos function, else SetPlayerPos
I'm not very pro but you mean like this?

Код:
dcmd_goto(playerid, params[])
	{
	#pragma unused params
    new ID;
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, COLOR_BLUE, "USAGE: /goto [ID]");
    else if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: {FFFFFF}This player is offline or it is yourself");
    if(toggoto[ID] == 1)
    {
	new string[50], name[MAX_PLAYER_NAME];
	format(string, sizeof(string), "%s's has Disabled goto! /toggoto", GetPlayerName(playerid, name, sizeof(name)));
	GameTextForPlayer(playerid,string,2000,3);
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	GetVehiclePos(vehicleid, x, y, z);
	SetVehiclePos(vehicleid, x+3, y ,z);
	return 1;
	}
	else
	{
  	new Float:x, Float:y, Float:z;
	GetPlayerPos(ID, x, y, z);
	SetPlayerPos(ID, x+2, y, z);
	}
	return 1;
	}
error 017: undefined symbol "vehicleid"
Reply
#10

No, I mean like this:
pawn Код:
// Command
new Float:x, Float:y, Float:z;
GetPlayerPos(ID, x, y, z);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetVehiclePos(GetPlayerVehicleID(playerid), x+3, y, z);
else SetPlayerPos(playerid, x+2, y, z); // On foot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)