SA-MP Forums Archive
CMD:gotoloc Needed - 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: CMD:gotoloc Needed (/showthread.php?tid=534072)



CMD:gotoloc Needed - Jigsaw123 - 27.08.2014

I need a GOTOLOC command..
For example..
When someone does :
/gotoloc fc
they get teleported to a specific position.


Re: CMD:gotoloc Needed - Twizted - 27.08.2014

You will need to read the following threads. Afterwards, you will be able to code as many commands as you wish.

https://sampforum.blast.hk/showthread.php?tid=120356
https://sampforum.blast.hk/showthread.php?tid=91354
https://sampforum.blast.hk/showthread.php?tid=280476
https://sampforum.blast.hk/showthread.php?tid=97349


Re: CMD:gotoloc Needed - Jigsaw123 - 27.08.2014

I've done this:

Код:
CMD:gotoloc(playerid, params[])
{
	    SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /gotoloc [LOCATION]");
	    SendClientMessage(playerid, COLOR_LIGHTBLUE, "To view all locations available, You may use /locations!");
	    return 1;
	if(!strcmp(params, "fc", true))
	{
	    SetPlayerInterior(playerid, 0);
	    SetPlayerVirtualWorld(playerid, 0);
	    SetPlayerPos(playerid,-193.1042,1002.7148,19.7789);
	    SendClientMessage(playerid, COLOR_WHITE, " You have teleported to Fort Carson.");
     	return 1;
	}
	else if(!strcmp(params, "dmv", true))
	{
	    SetPlayerInterior(playerid, 0);
	    SetPlayerVirtualWorld(playerid, 0);
	    SetPlayerPos(playerid,-92.4281,1090.8228,19.7422);
	    SendClientMessage(playerid, COLOR_WHITE, " You have teleported to the DMV.");
     	return 1;
	}
and got this error:

Код:
C:\Users\USER\Desktop\SV\gamemodes\bare.pwn(408) : warning 225: unreachable code
C:\Users\USER\Desktop\SV\gamemodes\bare.pwn(425) : error 030: compound statement not closed at the end of file (started at line 405)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: CMD:gotoloc Needed - R4PlaY - 27.08.2014

Try this with sscanf

if you don't have sscanf download it LINK TO SSCANF

and include it at top of the script

Код:
#include <sscanf2>
Код:
CMD:gotoloc(playerid, params[])
{
	new loc[ 4 ];
	if( sscanf( loc, "s[5] ", loc ) ) return SendClientMessage( playerid, -1, "USAGE: /gotoloc [fc/dmv]");

	if(!strcmp(loc, "fc", true))
	{
	    SetPlayerInterior(playerid, 0);
	    SetPlayerVirtualWorld(playerid, 0);
	    SetPlayerPos(playerid,-193.1042,1002.7148,19.7789);
	    SendClientMessage(playerid, -1, " You have teleported to Fort Carson.");
	}
	else if(!strcmp(loc, "dmv", true))
	{
	    SetPlayerInterior(playerid, 0);
	    SetPlayerVirtualWorld(playerid, 0);
	    SetPlayerPos(playerid,-92.4281,1090.8228,19.7422);
	    SendClientMessage(playerid, -1, " You have teleported to the DMV.");
	}
	return (1);
}



Re: CMD:gotoloc Needed - Jigsaw123 - 27.08.2014

The script gives me no error, but the Gamemode becomes UNKNOWN


Re: CMD:gotoloc Needed - Sarra - 27.08.2014

pawn Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
pawn Код:
CMD:gotoloc(playerid, params[])
{
    if (isnull(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /gotoloc [LOCATION]");
   
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "To view all locations available, You may use /locations!");
    if(!strcmp(params, "fc", true))
    {
        SetPlayerInterior(playerid, 0);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerPos(playerid,-193.1042,1002.7148,19.7789);
        SendClientMessage(playerid, COLOR_WHITE, " You have been teleported to Fort Carson.");

    }
    else if(!strcmp(params, "dmv", true))
    {
        SetPlayerInterior(playerid, 0);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerPos(playerid,-92.4281,1090.8228,19.7422);
        SendClientMessage(playerid, COLOR_WHITE, " You have been teleported to the DMV.");

    }
return 1;
}
------------
Quote:

The script gives me no error, but the Gamemode becomes UNKNOWN

You probably didn't COPY/PASTE Everything in the right directories (sscanf folder, sscanf plugin and sscanf2.INC)
Also don't forget to add: "plugins sscanf" in your server cfg