SA-MP Forums Archive
Goto Command - 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: Goto Command (/showthread.php?tid=290332)



Goto Command - Kostas' - 15.10.2011

I made a /goto [id] command but I got errors.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    if ( strcmp( cmd, "/Goto", true ) == 0 ) {
        new id = strval(cmdtext);
        else if(!strlen(cmdtext)) return SendClientMessage(playerid, 0xFF0000AA, "/Goto [playerid]");
        else if(id == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You cannot goto yourself...");
        else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "Player is not connected");
        else
        {
            new tmp[256];
            tmp = strtok( cmdtext, idx );
            if ( !strlen( tmp ) ) { return 1; }
            new Float:X, Float:Y, Float:Z, Pname[24];
            GetPlayerPos( strval(tmp), X, Y, Z );
            ResetPlayerWeapons(playerid);
            if (GetPlayerState(playerid)==PLAYER_STATE_DRIVER)SetVehiclePos( GetPlayerVehicleID(playerid), X+2, Y+2, Z );
            else SetPlayerPos( playerid, X+2, Y+2, Z );
            new String[56];
            format(String, sizeof(String), "You have teleported to %s(%d)", Pname, id);
            SendClientMessage(playerid, 0xFF0000AA, String);
        }
        return 1;
}
//More
What is wrong with it?
Line 5647
pawn Код:
else if(!strlen(cmdtext)) return SendClientMessage(playerid, 0xFF0000AA, "/g [playerid]");
These the errors.
pawn Код:
C:\Documents and Settings\orion\Фб ЭггсбцЬ мпх\Downloads\samp03csvr_R2-2_win32 (2)\gamemodes\Xtreamgaming.pwn(5647) : error 029: invalid expression, assumed zero
C:\Documents and Settings\orion\Фб ЭггсбцЬ мпх\Downloads\samp03csvr_R2-2_win32 (2)\gamemodes\Xtreamgaming.pwn(5647) : warning 215: expression has no effect
C:\Documents and Settings\orion\Фб ЭггсбцЬ мпх\Downloads\samp03csvr_R2-2_win32 (2)\gamemodes\Xtreamgaming.pwn(5647) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.



Re: Goto Command - Josma_cmd - 15.10.2011

remove the else.
pawn Код:
new id = strval(cmdtext); /*change to*/ new id = strval(cmd);
pawn Код:
if(!strlen(cmd)) return SendClientMessage(playerid, 0xFF0000AA, "/Goto [playerid]");



Re: Goto Command - Kostas' - 15.10.2011

Thanks, I thought because I have already the if, should have else if. My bad :P
Something else what is wrong with it
pawn Код:
new String[56];
            format(String, sizeof(String), "You have teleported to %s(%d)", Pname, id);
            SendClientMessage(playerid, 0xFF0000AA, String);
When I teleport a player it says
Код:
You have teleported to (0)
Every id I use it says the same (0)


Re: Goto Command - iJumbo - 15.10.2011

Edit:FAIL


Re: Goto Command - Josma_cmd - 15.10.2011

pawn Код:
GetPlayerName(strval(tmp), Pname, sizeof(Pname));
format(String, sizeof(String), "You have teleported to %s(%d)", Pname, strval(tmp));



Re: Goto Command - SmiT - 15.10.2011

pawn Код:
GetPlayerName( strval( tmp ), Pname, sizeof ( Pname ) );



Re: Goto Command - Kostas' - 15.10.2011

Quote:
Originally Posted by [ISS]jumbo
Посмотреть сообщение
Edit:FAIL
It was. You didn't
pawn Код:
new tmp[256];
Quote:
Originally Posted by Josma_cmd
Посмотреть сообщение
pawn Код:
GetPlayerName(strval(tmp), Pname, sizeof(Pname));
format(String, sizeof(String), "You have teleported to %s(%d)", Pname, strval(tmp));
Thanks it works.

Moreover, Can I SendClientMessage to the player, to know who teleported to him.
Like for example
pawn Код:
format(String, sizeof(String), "%s(%d) has teleported to %s(%d)",playerid, Pname, strval(tmp));



Re: Goto Command - Josma_cmd - 15.10.2011

Yes, see if this work.

pawn Код:
GetPlayerName(strval(tmp), Pname, sizeof(Pname));
format(String, sizeof(String), "You have teleported to %s(%d)", Pname, strval(tmp));
SendClientMessage(playerid, COLOR, String);
GetPlayerName(playerid, Pname, sizeof(Pname));
format(String, sizeof(String), "%s(%d) was teleported to you", Pname, playerid);
SendClientMessage(strval(tmp), COLOR, String);



Re: Goto Command - Kostas' - 15.10.2011

Quote:
Originally Posted by Josma_cmd
Посмотреть сообщение
Yes, see if this work.

pawn Код:
GetPlayerName(strval(tmp), Pname, sizeof(Pname));
format(String, sizeof(String), "You have teleported to %s(%d)", Pname, strval(tmp));
SendClientMessage(playerid, COLOR, String);
GetPlayerName(playerid, Pname, sizeof(Pname));
format(String, sizeof(String), "%s(%d) was teleported to you", Pname, playerid);
SendClientMessage(strval(tmp), COLOR, String);
Thanks, it compiles, but I can't test it to see if it works, because I test them on localhost:7777 before upload them on the server.
I guess it will works!


Re: Goto Command - Josma_cmd - 15.10.2011

No problema. =)