Problem with allowing goto and not allowing it. HELP!
#1

Hello everyone. I have been trying to make a command that lets the player choose if people can goto him or not.
The problem is that when I was testing it with my friends, when they had /ngoto which means do not allow goto, i could still goto him, or it it could happen the opposite way, if they have /sgoto which means allow goto, I could not goto him, or sometimes it would work. Its just a mess and im not sure how to fix it.

Code:

pawn Код:
new gotoa[MAX_PLAYERS]; //this is on top, after the #defines

public OnPlayerConnect(playerid)
{
  gotoa[playerid] = 1;
    return 1;
}

new id;

COMMAND:sgoto(playerid, params[])
{
if (gotoa[playerid] == 1){
SendClientMessage(playerid, COLOR_LRED, "Ya tienes el goto activado");
}
else
{
gotoa[playerid] = 1;
SendClientMessage(playerid, COLOR_GREEN, "Las personas ahora te pueden hacer goto");
}
return 1;
}

COMMAND:ngoto(playerid, params[])
{
if (gotoa[playerid] == 0){
SendClientMessage(playerid, COLOR_LRED, "El goto ya lo tienes desactivado!");
}
else
{
gotoa[playerid] = 0;
SendClientMessage(playerid, COLOR_RED, "Las personas ahora NO te pueden hacer goto");
}
return 1;
}

COMMAND:goto(playerid, params[])
{
    if (gotoa[id] == 1){
    if (strlen(params))
    {
        id = strval(params);
        if (IsPlayerConnected(id))
        {
            new Float:x, Float:y, Float:z;
            GetPlayerPos(id, x, y, z);
            new name[MAX_PLAYER_NAME], string[48];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "%s se teletransporto a ti.", name);
        SendClientMessage(id, COLOR_LRED, string);
            SetPlayerPos(playerid, x, y, z);

        GetPlayerName(id, name, sizeof(name));
        format(string, sizeof(string), "Hiciste goto a %s ", name);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        }
        else
        {
          SendClientMessage(playerid, COLOR_LRED, "El jugador no fue encontrado");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_LRED, "Usage: /goto [ID/Parte del nombre]");
    }
    }
    else if (gotoa[id] == 0)
    {
      SendClientMessage(playerid, COLOR_RED, "Esta persona tiene el goto desactivado");
    }
    return 1;
}
Thank you, any help will be appreciated.
Reply
#2

anyone?
Reply
#3

Change this lines in goto:
pawn Код:
if (gotoa[id] == 1){
if (strlen(params))
{
id = strval(params);
To this:
pawn Код:
id = strval(params);
if (gotoa[id] == 1){
if (strlen(params))
{
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)