Help with teleport command
#1

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;
}
Reply
#2

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;
}
Reply
#3

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)