/goto system
#1

Hello there!
I am currently using this code for /go commands, which allows me to allow or not people that are trying to /go to me.

pawn Код:
// Player's Teleport system.
//     By Lordz™.
//Topic : https://sampforum.blast.hk/showthread.ph...pid2086387
//Author: Lordz™.
//Version:BETA v1
//Released Date: 29/08/2012
//How to use:?
//Use /teleon to enable tele command.
//Note that if you enable tele command,others will be able to teleport to you using /ptele
//teleoff to disable tele command.
//ptele to teleport to a player.
//Note that you can only teleport to other using ptele if other has enabled tele command.
//mtele to teleport to a player by spending money.
//telecmds to view commands.
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define FILTERSCRIPT


#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Player's teleport system loaded.");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
#endif
//============================================================================================================
                                   //Player's Teleport system by Lordz™.
//=============================================================================================================*/

#define red 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
//#define mtele
//Uncomment this to disable money goto(/mtele)
#define orange 0xFF9900AA
#define green 0x33FF33AA
new tele[MAX_PLAYERS];

CMD:gon(playerid,params[])
{
   if(tele[playerid]==1)
   return SendClientMessage(playerid, COLOR_YELLOW, "You've already enabled GO command. Use /goff");
   tele[playerid]=1;
   SendClientMessage(playerid, COLOR_YELLOW, "You've enabled tele command. Note that others can teleport to you.");
   return 1;
}

CMD:goff(playerid,params[])
{
   if(tele[playerid]==0)
   return SendClientMessage(playerid, COLOR_YELLOW, "You've already disabled GO command. Use /gon to enable.");
   tele[playerid]=0;
   SendClientMessage(playerid, COLOR_YELLOW, "Your tele command has been turned off.");
   return 1;
}

CMD:go(playerid,params[])
{
   new teleid;
   if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /go [playerid]");
//   if(IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected");
   if(tele[teleid]==1) return SendClientMessage(playerid, COLOR_YELLOW, "Player has disabled GO command..");
   new Float:telex,Float:teley,Float:telez,int;
   GetPlayerPos(teleid,telex,teley,telez);
   int = GetPlayerInterior(teleid);
   SetPlayerPos(playerid,telex,teley,telez);
   SetPlayerInterior(playerid,int);
   return 1;
}


#if defined mtele
CMD:mtele(playerid,params[])
{
   if(GetPlayerMoney(playerid)<5000) return SendClientMessage(playerid, COLOR_YELLOW, "You need $5000 to use this command.");
   new target;
   if(sscanf(params,"u",target)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage:/mtele [playerid]");
//   if(IsPlayerConnected(target)) return SendClientMessage(playerid, red, "Player isnt connected");
   GivePlayerMoney(playerid,-5000);
   new Float:x,Float:y,Float:z,mint;
   GetPlayerPos(target,x,y,z);
   mint = GetPlayerInterior(target);
   SetPlayerPos(playerid,x,y,z);
   SetPlayerInterior(playerid,mint);
   SendClientMessage(playerid, red, "You've successfully used /mtele using $5000.");
   return 1;
}
#endif
//Hope you will enjoy the script.
It seems like the /go works, but actually it doesn't allow me to disable it, even if it says "Your tele command has been turned off"
Have you got any suggestions for me? Or maybe another system!
Thanks!
Reply
#2

pawn Код:
// Player's Teleport system.
//     By Lordz™.
//Topic : https://sampforum.blast.hk/showthread.ph...pid2086387
//Author: Lordz™.
//Version:BETA v1
//Released Date: 29/08/2012
//How to use:?
//Use /teleon to enable tele command.
//Note that if you enable tele command,others will be able to teleport to you using /ptele
//teleoff to disable tele command.
//ptele to teleport to a player.
//Note that you can only teleport to other using ptele if other has enabled tele command.
//mtele to teleport to a player by spending money.
//telecmds to view commands.
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define FILTERSCRIPT


#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Player's teleport system loaded.");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
#endif
//============================================================================================================
                                   //Player's Teleport system by Lordz™.
//=============================================================================================================*/

#define red 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
//#define mtele
//Uncomment this to disable money goto(/mtele)
#define orange 0xFF9900AA
#define green 0x33FF33AA
new tele[MAX_PLAYERS];

CMD:gon(playerid,params[])
{
   if(tele[playerid]==1)
   return SendClientMessage(playerid, COLOR_YELLOW, "You've already enabled GO command. Use /goff");
   tele[playerid]=1;
   SendClientMessage(playerid, COLOR_YELLOW, "You've enabled tele command. Note that others can teleport to you.");
   return 1;
}

CMD:goff(playerid,params[])
{
   if(tele[playerid]==0)
   return SendClientMessage(playerid, COLOR_YELLOW, "You've already disabled GO command. Use /gon to enable.");
   tele[playerid]=0;
   SendClientMessage(playerid, COLOR_YELLOW, "Your tele command has been turned off.");
   return 1;
}

CMD:go(playerid,params[])
{
   new teleid;
   if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /go [playerid]");
//   if(IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected");
   if(tele[teleid]==0) return SendClientMessage(playerid, COLOR_YELLOW, "Player has disabled GO command..");
   new Float:telex,Float:teley,Float:telez,int;
   GetPlayerPos(teleid,telex,teley,telez);
   int = GetPlayerInterior(teleid);
   SetPlayerPos(playerid,telex,teley,telez);
   SetPlayerInterior(playerid,int);
   return 1;
}


#if defined mtele
CMD:mtele(playerid,params[])
{
   if(GetPlayerMoney(playerid)<5000) return SendClientMessage(playerid, COLOR_YELLOW, "You need $5000 to use this command.");
   new target;
   if(sscanf(params,"u",target)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage:/mtele [playerid]");
//   if(IsPlayerConnected(target)) return SendClientMessage(playerid, red, "Player isnt connected");
   GivePlayerMoney(playerid,-5000);
   new Float:x,Float:y,Float:z,mint;
   GetPlayerPos(target,x,y,z);
   mint = GetPlayerInterior(target);
   SetPlayerPos(playerid,x,y,z);
   SetPlayerInterior(playerid,mint);
   SendClientMessage(playerid, red, "You've successfully used /mtele using $5000.");
   return 1;
}
#endif
//Hope you will enjoy the script.
Small typo I guess. Okay so what happened is next: He said that when player types /GOOFF the variable 'tele' is being set to 0. But when he uses /go, he checks if the variable is 1. I just changed it so when player tries to /go to a certain player, checks if the other player has 'tele==0' and if he has, he won't be able to. That's about it, hope it helps!
Reply
#3

It now works! There's a little problem. I'm trying it out on my home server before uploading it in a new version of my hosted one.. And after I type /go 0 ( I TP to myself ) once but usually twice, my server crashes.
Sometimes the first time the teleport works, telling me "You have teleported to Zero"
I just added
pawn Код:
SendClientMessage(playerid, COLOR_YELLOW, "You've teleported to %s");
To this:
pawn Код:
CMD:go(playerid,params[])
{
   new teleid;
   if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /go [playerid]");
//   if(IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected");
   if(tele[teleid]==0) return SendClientMessage(playerid, COLOR_YELLOW, "Player has disabled GO command.");
   new Float:telex,Float:teley,Float:telez,int;
   GetPlayerPos(teleid,telex,teley,telez);
   int = GetPlayerInterior(teleid);
   SetPlayerPos(playerid,telex,teley,telez);
   SetPlayerInterior(playerid,int);
   SendClientMessage(playerid, COLOR_YELLOW, "You've teleported to %s");
   return 1;
}
Did I do something wrong?

Mhm.. I thought.. Do I have to add this?
pawn Код:
GetPlayerName(playerid, name, sizeof(name));
Reply
#4

Quote:
Originally Posted by Polonio9
Посмотреть сообщение
It now works! There's a little problem. I'm trying it out on my home server before uploading it in a new version of my hosted one.. And after I type /go 0 ( I TP to myself ) once but usually twice, my server crashes.
Sometimes the first time the teleport works, telling me "You have teleported to Zero"
I just added
pawn Код:
SendClientMessage(playerid, COLOR_YELLOW, "You've teleported to %s");
To this:
pawn Код:
CMD:go(playerid,params[])
{
   new teleid;
   if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /go [playerid]");
//   if(IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected");
   if(tele[teleid]==0) return SendClientMessage(playerid, COLOR_YELLOW, "Player has disabled GO command.");
   new Float:telex,Float:teley,Float:telez,int;
   GetPlayerPos(teleid,telex,teley,telez);
   int = GetPlayerInterior(teleid);
   SetPlayerPos(playerid,telex,teley,telez);
   SetPlayerInterior(playerid,int);
   SendClientMessage(playerid, COLOR_YELLOW, "You've teleported to %s");
   return 1;
}
Did I do something wrong?

Mhm.. I thought.. Do I have to add this?
pawn Код:
GetPlayerName(playerid, name, sizeof(name));
pawn Код:
CMD:go(playerid,params[])
{
   new teleid;
    new MSG[250];
GetPlayerName(playerid, teleid,sizeof(teleid);
   if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /go [playerid]");
//   if(IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected");
   if(tele[teleid]==0) return SendClientMessage(playerid, COLOR_YELLOW, "Player has disabled GO command.");
   new Float:telex,Float:teley,Float:telez,int;
   GetPlayerPos(teleid,telex,teley,telez);
   int = GetPlayerInterior(teleid);
   SetPlayerPos(playerid,telex,teley,telez);
   SetPlayerInterior(playerid,int);
   format(MSG,sizeof(MSG),"You've teleported to %s",teleid);
SendClientMessage(playerid, COLOR_YELLOW, MSG);
   return 1;
}
Reply
#5

I get this using ThePhenix's code: "error 035: argument type mismatch (argument 2)"

The error happens in this line:
pawn Код:
GetPlayerName(playerid, teleid, sizeof(teleid);
Reply
#6

new teleid[MAX_PLAYER_NAME]; - Use this.
Reply
#7

D:\GIULIO\Varie\server2\filterscripts\GO.pwn(71) : error 001: expected token: ",", but found ";"
D:\GIULIO\Varie\server2\filterscripts\GO.pwn(74) : error 033: array must be indexed (variable "teleid")
D:\GIULIO\Varie\server2\filterscripts\GO.pwn(76) : error 035: argument type mismatch (argument 1)
D:\GIULIO\Varie\server2\filterscripts\GO.pwn(77) : error 035: argument type mismatch (argument 1)

Line 71 is
pawn Код:
GetPlayerName(playerid, teleid, sizeof(teleid);
Line 74 is
pawn Код:
if(tele[teleid]==0) return SendClientMessage(playerid, COLOR_YELLOW, "Player has disabled GO command.");
Line 76 is
pawn Код:
GetPlayerPos(teleid,telex,teley,telez);
Line 77 is
pawn Код:
int = GetPlayerInterior(teleid);
My code is
pawn Код:
CMD:go(playerid,params[])
{
   new teleid[MAX_PLAYER_NAME];
   new MSG[250];
   GetPlayerName(playerid, teleid, sizeof(teleid);
   if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /go [playerid]");
//   if(IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected");
   if(tele[teleid]==0) return SendClientMessage(playerid, COLOR_YELLOW, "Player has disabled GO command.");
   new Float:telex,Float:teley,Float:telez,int;
   GetPlayerPos(teleid,telex,teley,telez);
   int = GetPlayerInterior(teleid);
   SetPlayerPos(playerid,telex,teley,telez);
   SetPlayerInterior(playerid,int);
   format(MSG,sizeof(MSG),"You've teleported to %s",teleid);
   SendClientMessage(playerid, COLOR_YELLOW, MSG);
   return 1;
}
Reply
#8

pawn Код:
CMD:go( playerid, params[ ] )
{
    new
        teleid,
        pname[ MAX_PLAYER_NAME ],
        MSG[ 128 ]
    ;
    GetPlayerName( teleid, pname, sizeof( pname ) );
    if( sscanf( params, "u", teleid ) ) return SendClientMessage( playerid, COLOR_YELLOW, "Usage: /go [playerid]" );
    // if( IsPlayerConnected( teleid ) ) return SendClientMessage( playerid, red, "Player is not connected" );
    if( tele[ teleid ] == 0 ) return SendClientMessage( playerid, COLOR_YELLOW, "Player has disabled GO command." );
    new
        Float:pos[ 3 ]
    ;
    GetPlayerPos( teleid, pos[ 0 ], pos[ 1 ], pos[ 2 ] );
    SetPlayerPos( playerid, pos[ 0 ], pos[ 1 ], pos[ 2 ] );
    SetPlayerInterior( playerid, GetPlayerInterior( teleid ) );
    format( MSG, sizeof( MSG ), "You've teleported to %s", pname );
    SendClientMessage( playerid, COLOR_YELLOW, MSG );
    return 1;
}
Reply
#9

Oh my bad I didn't saw that you don't have name of target player. Dwane's code should work fine.
Reply
#10

Thank you, it works perfectly!
May I have your skype contact please Dwayne?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)