SA-MP Forums Archive
[Filterscript] Need /goto toogle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Filterscript] Need /goto toogle (/showthread.php?tid=310784)



[Filterscript] Need /goto toogle - ixesas - 13.01.2012

Hi, i want to ask you to made a few ladmin functions. (dcmd)
/Goto ON and OFF toogle.

/gotoon
/gotooff

When player wrote /gotoon - players can /goto to him
When player wrote /gotoff - players can't /goto to him.

Please somebody make this functions, thx.
Srry for bad language.


Re: [Filterscript] Need /goto toogle - Snowman12 - 13.01.2012

Wrong section. Post in scripting requests...


Re: [Filterscript] Need /goto toogle - ixesas - 13.01.2012

I have moved here...


Re: [Filterscript] Need /goto toogle - Soumi - 13.01.2012

Well, first of all, create a var ( new GotoStatus[MAX_PLAYERS]; ) at the top of your game mode.
Then, when the player enters the /gotoon cmd the var status will be changed to 1 ( GotoStatus[playerid] = 1; ).
And when he types the /gotooff cmd, the var status will be changed to 0 ( GotoStatus[playerid] = 0; ).
And when the player types /goto [ID], it will check if the target ID goto is on:

pawn Код:
if(GotoStatus[targetid] == 1)
{
    //Apply your /goto cmd here (The teleports etc)
}
else if(GotoStatus[targetid] == 0) return 0;
You can find the /goto cmd in DCMD by using search (It will be good if you use sscanf2 too).

I hope i helped you.


Re: [Filterscript] Need /goto toogle - Mean - 13.01.2012

pawn Код:
new gotost[MAX_PLAYERS];

public OnPlayerConnect(playerid) {
    gotost[playerid] = 0; // 0 by default
    return 1;
}

CMD:togglegoto(playerid, params[]) {
    if(gotost[playerid] == 1) {
        SendClientMessage(playerid, -1, "Players can no longer teleport to you.");
        gotost[playerid] = 0;
    }
    else {
        SendClientMessage(playerid, -1, "Players can now teleport to you.");
        gotost[playerid] = 1;
    }
    return 1;
}
And in the goto command, add:

pawn Код:
if(gotost[id] == 1) {
    // teleport code
}
else SendClientMessage(playerid, -1, "You cannot teleport to this player.");



Re: [Filterscript] Need /goto toogle - ixesas - 14.01.2012

Quote:
Originally Posted by Mean
Посмотреть сообщение
pawn Код:
new gotost[MAX_PLAYERS];

public OnPlayerConnect(playerid) {
    gotost[playerid] = 0; // 0 by default
    return 1;
}

CMD:togglegoto(playerid, params[]) {
    if(gotost[playerid] == 1) {
        SendClientMessage(playerid, -1, "Players can no longer teleport to you.");
        gotost[playerid] = 0;
    }
    else {
        SendClientMessage(playerid, -1, "Players can now teleport to you.");
        gotost[playerid] = 1;
    }
    return 1;
}
And in the goto command, add:

pawn Код:
if(gotost[id] == 1) {
    // teleport code
}
else SendClientMessage(playerid, -1, "You cannot teleport to this player.");
Where exactly should i put
pawn Код:
if(gotost[id] == 1) {
code?
Because when i put it like this:

pawn Код:
dcmd_goto(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 0 || IsPlayerAdmin(playerid)) {
    if(gotost[id] == 1) {
        if(!strlen(params)) return SendClientMessage(playerid,red,"{FF0000}Use{FFFFFF}: /Goto [PlayerID]");
        new player1, string[128];
        if(!IsNumeric(params)) player1 = ReturnPlayerID(params);
        else player1 = strval(params);
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid) {
            CMDMessageToAdmins(playerid,"GOTO");
            new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z); SetPlayerInterior(playerid,GetPlayerInterior(player1));
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
            if(GetPlayerState(playerid) == 2) {
                SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);    LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
                SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
            } else SetPlayerPos(playerid,x+2,y,z);
            format(string,sizeof(string),"{FFFFFF}You have teleported to {FF0000}\"%s\"", pName(player1));
            return SendClientMessage(playerid,blue,string);
                        else SendClientMessage(playerid, -1, "You cannot teleport to yourself.");
        } else return SendClientMessage(playerid, red, "{FF0000}Player is not connected.");
    } else return SendClientMessage(playerid,red,"{FF0000}Error{FFFFFF}: This command is only for Members");
}
i get a lot of errors..

And by the way. How to fix error error 017: undefined symbol "id" ?
The line is:
pawn Код:
if(gotost[id] == 1) {



Re: [Filterscript] Need /goto toogle - Mean - 14.01.2012

pawn Код:
dcmd_goto(playerid,params[]) {
    if(!strlen(params)) return SendClientMessage(playerid,red,"{FF0000}Use{FFFFFF}: /Goto [PlayerID]");
    new player1, string[128];
    if(!IsNumeric(params)) player1 = ReturnPlayerID(params);
    else player1 = strval(params);
    if(gotost[player1] == 0 && PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid, red, "Error: you can't teleport to this player right now.");
    if(!IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID || player1 == playerid) return SendClientMessage(playerid, red, "Player is either not connected or is you.");
    CMDMessageToAdmins(playerid,"GOTO");
    new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z); SetPlayerInterior(playerid,GetPlayerInterior(player1));
    SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
    if(GetPlayerState(playerid) == 2) {
        SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
        LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
        SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
    }
    else SetPlayerPos(playerid,x+2,y,z);
    format(string,sizeof(string),"{FFFFFF}You have teleported to {FF0000}\"%s\"", pName(player1));
    return SendClientMessage(playerid,blue,string);
}



Re: [Filterscript] Need /goto toogle - ixesas - 14.01.2012

C:\Users\User\Desktop\DCV2\filterscripts\ladmin4v2 .pwn(1862) : warning 209: function "dcmd_goto" should return a value
C:\Users\User\Desktop\DCV2\filterscripts\ladmin4v2 .pwn(1862) : error 010: invalid function or declaration

/imageshack/img638/9199/goto.png

C:\Users\User\Desktop\DCV2\filterscripts\ladmin4v2 .pwn(2652) : warning 203: symbol is never used: "params"

/imageshack/img638/171/igoto.png


Re: [Filterscript] Need /goto toogle - Mean - 14.01.2012

Edited my previous post, use that goto.

About the warning:
pawn Код:
dcmd_igoto(playerid,params[]) {
    #pragma unused params
    if(gotost[playerid] == 1) {
        SendClientMessage(playerid, -1, "Players can no longer teleport to you.");
        gotost[playerid] = 0;
    }
    else {
        SendClientMessage(playerid, -1, "Players can now teleport to you.");
        gotost[playerid] = 1;
    }
    return 1;
}



Re: [Filterscript] Need /goto toogle - ixesas - 14.01.2012

Quote:
Originally Posted by Mean
Посмотреть сообщение
Edited my previous post, use that goto.

About the warning:
pawn Код:
dcmd_igoto(playerid,params[]) {
    #pragma unused params
    if(gotost[playerid] == 1) {
        SendClientMessage(playerid, -1, "Players can no longer teleport to you.");
        gotost[playerid] = 0;
    }
    else {
        SendClientMessage(playerid, -1, "Players can now teleport to you.");
        gotost[playerid] = 1;
    }
    return 1;
}
/igoto command doesn't work.
SERVER: Unknown command