Goto Enable and Disable
#1

Hello, in this script i want to do a goto command that can teleport player to another player, but if one player have goto disabled he can't teleport and receive teleport from another player.
This is the code:
if(strcmp(cmd, "/goto", true) == 0)
{
new string[128];
new tmp[128];
new Float: poscord[3];
new On[128];
new Off[128];
On = "On";
Off = "Off";
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /goto [playerid]");
else if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,COLOR_RED,"Player non trovato"); // PLAYER NOT FOUNDED
else if(tmp = Off) return PlayerInfo[playerid][GOnOff] = 1; //i have the problem in this line
else if(tmp = On) return PlayerInfo[playerid][GOnOff] = 0; //i have the problem in this line
else if(PlayerInfo[strval(tmp)][GOnOff] == 1) return SendClientMessage(playerid,COLOR_RED,"Il giocatore ha disattivato il goton"); // the player have deactivate the goto
GetPlayerPos(strval(tmp),poscord[0],poscord[1],poscord[2]);
SetPlayerPos(playerid,poscord[0],poscord[1],poscord[2]);
GetPlayerName(strval(tmp),PlayerInfo[playerid][pname],MAX_PLAYER_NAME);
format(string,128,"ti sei teletrasportato da %s",PlayerInfo[playerid][pname]);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string) ;
return 1;
}
Reply
#2

The lines on which you say you "have a problem" are NOT needed. Just remove them.
Reply
#3

Oh my god.
1) Use [ pawn ] tags.
2) Use zcmd and sscanf
3) Why 128 for "On"? Why?
4) Why 128 for "Off"?

pawn Код:
new bool: gotoState[ MAX_PLAYERS ] = {false, ...};
CMD:goto(playerid, params[])
{
    new target;
    if(!sscanf(params, "u", target)) {
        if(gotoState[target]) {
            new Float: x, Float: y, Float: z;
            GetPlayerPos(target, x, y, z);
            SetPlayerPos(playerid, x, y, z);
        }
        else return SendClientMessage(playerid,COLOR_RED,"Il giocatore ha disattivato il goton");
      }
      else return SendClientMessage(playerid, COLOR_RED, "USAGE: /goto [playerid]");
      return 1;
}

CMD:mygoto(playerid, params[])
{
    gotoState[playerid] = !gotoState[playerid];
    return 1;
}
Reply
#4

One moment i try it.
I'm italian and i don't speak english very well so sorry for bad english.
Reply
#5

No i want if the player do /goto off i want to do if(cmdtext = "off") do PlayerInfo[playerid][GOnOff] = 1;
Reply
#6

[RESOLVED]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)