SA-MP Forums Archive
Help with teleport 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with teleport command (/showthread.php?tid=228732)



Help with teleport command - Markx - 20.02.2011

Okay, i got 2 teleport commands: /chiliad1 /chiliad.

The Problem is when i tipe /chiliad1 it brings me to /chiliad, and when i tipe /chiliad it brings me to the right possition...

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/chiliad", cmdtext, true, 5) == 0)
    {
        SetPlayerPos(playerid, -2235.6418,-1738.8710,480.8144);
        SetPlayerFacingAngle(playerid, 206.4987);
        GivePlayerWeapon(playerid, 46, 500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 10.0);
        return 1;
    }
    if(strcmp("/chiliad1", cmdtext, true, 5) == 0)
    {
        SetPlayerPos(playerid, -2312.3948,-1663.9303,623.5829);
        SetPlayerFacingAngle(playerid, 152.0016);
        GivePlayerWeapon(playerid, 46, 500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 10.0);
        return 1;
    }
    return 0;
}



Re: Help with teleport command - Mauzen - 20.02.2011

if(strcmp("/chiliad", cmdtext, true, 5)

The 5 means, only the first 5 characters are compared. SO /chiliad and /chiliad1 are the same. Just remove the 5 in both lines, so it will check all characters:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/chiliad", cmdtext, true) == 0)
    {
        SetPlayerPos(playerid, -2235.6418,-1738.8710,480.8144);
        SetPlayerFacingAngle(playerid, 206.4987);
        GivePlayerWeapon(playerid, 46, 500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 10.0);
        return 1;
    }
    if(strcmp("/chiliad1", cmdtext, true) == 0)
    {
        SetPlayerPos(playerid, -2312.3948,-1663.9303,623.5829);
        SetPlayerFacingAngle(playerid, 152.0016);
        GivePlayerWeapon(playerid, 46, 500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 10.0);
        return 1;
    }
    return 0;
}



Re: Help with teleport command - Markx - 20.02.2011

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
if(strcmp("/chiliad", cmdtext, true, 5)

The 5 means, only the first 5 characters are compared. SO /chiliad and /chiliad1 are the same. Just remove the 5 in both lines, so it will check all characters:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/chiliad", cmdtext, true) == 0)
    {
        SetPlayerPos(playerid, -2235.6418,-1738.8710,480.8144);
        SetPlayerFacingAngle(playerid, 206.4987);
        GivePlayerWeapon(playerid, 46, 500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 10.0);
        return 1;
    }
    if(strcmp("/chiliad1", cmdtext, true) == 0)
    {
        SetPlayerPos(playerid, -2312.3948,-1663.9303,623.5829);
        SetPlayerFacingAngle(playerid, 152.0016);
        GivePlayerWeapon(playerid, 46, 500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 10.0);
        return 1;
    }
    return 0;
}
Thanks mate!