SA-MP Forums Archive
Problems with using 2 floats in one 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: Problems with using 2 floats in one command (/showthread.php?tid=271437)



Problems with using 2 floats in one command - Jack_Leslie - 24.07.2011

So I have a /lock command.. (and it's not in DCMD or ZCMD, which I know isn't good so please don't remind me about that). Anyway, the first half works, if the player is in range of the "l1" point, it works, but it doesn't detect the other half, if the player is in range of the "l2" point, it just acts like that code isn't even working.

pawn Код:
if(strcmp(cmd, "/lock", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new linkcar1 = PlayerInfo[playerid][CarLinkID];
            new linkcar2 = PlayerInfo[playerid][Car2LinkID];
            new Float:l1x, Float:l1y, Float:l1z;
            new Float:l2x, Float:l2y, Float:l2z;
            GetVehiclePos(linkcar2, l2x, l2y, l2z);
            GetVehiclePos(linkcar1, l1x, l1y, l1z);
            if(IsPlayerInRangeOfPoint(playerid, 4, l1x, l1y, l1z))
            {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                if(gCarLock[linkcar1] == 1)
                {
                    PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
                    if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has unlocked their vehicle.");
                    else format(string, sizeof(string), "* %s has unlocked their vehicle.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    UnLockCar(linkcar1);
                }
                else
                {
                    if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
                    else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
                    LockCar(linkcar1);
                }
        if(IsPlayerInRangeOfPoint(playerid, 4, l2x, l2y, l2z))
            {
                if(gCarLock[linkcar2] == 1)
                {
                    PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
                    if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has unlocked their vehicle.");
                    else format(string, sizeof(string), "* %s has unlocked their vehicle.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    UnLockCar(linkcar2);
                }
                else
                {
                    if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
                    else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
                    LockCar(linkcar2);
                }
            }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are too far away from your vehicle !");
                return 1;
            }
        }
        return 1;
    }



Re: Problems with using 2 floats in one command - MadeMan - 24.07.2011

pawn Код:
if(strcmp(cmd, "/lock", true) == 0)
{
    new linkcar1 = PlayerInfo[playerid][CarLinkID];
    new linkcar2 = PlayerInfo[playerid][Car2LinkID];
    new Float:l1x, Float:l1y, Float:l1z;
    new Float:l2x, Float:l2y, Float:l2z;
    GetVehiclePos(linkcar2, l2x, l2y, l2z);
    GetVehiclePos(linkcar1, l1x, l1y, l1z);
    if(IsPlayerInRangeOfPoint(playerid, 4, l1x, l1y, l1z))
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(gCarLock[linkcar1] == 1)
        {
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has unlocked their vehicle.");
            else format(string, sizeof(string), "* %s has unlocked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            UnLockCar(linkcar1);
        }
        else
        {
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
            else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            LockCar(linkcar1);
        }
    }
    else if(IsPlayerInRangeOfPoint(playerid, 4, l2x, l2y, l2z))
    {
        if(gCarLock[linkcar2] == 1)
        {
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has unlocked their vehicle.");
            else format(string, sizeof(string), "* %s has unlocked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            UnLockCar(linkcar2);
        }
        else
        {
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
            else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            LockCar(linkcar2);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "   You are too far away from your vehicle !");
        return 1;
    }
    return 1;
}
Brackets...


Re: Problems with using 2 floats in one command - Jack_Leslie - 24.07.2011

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/lock", true) == 0)
{
    new linkcar1 = PlayerInfo[playerid][CarLinkID];
    new linkcar2 = PlayerInfo[playerid][Car2LinkID];
    new Float:l1x, Float:l1y, Float:l1z;
    new Float:l2x, Float:l2y, Float:l2z;
    GetVehiclePos(linkcar2, l2x, l2y, l2z);
    GetVehiclePos(linkcar1, l1x, l1y, l1z);
    if(IsPlayerInRangeOfPoint(playerid, 4, l1x, l1y, l1z))
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(gCarLock[linkcar1] == 1)
        {
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has unlocked their vehicle.");
            else format(string, sizeof(string), "* %s has unlocked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            UnLockCar(linkcar1);
        }
        else
        {
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
            else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            LockCar(linkcar1);
        }
    }
    else if(IsPlayerInRangeOfPoint(playerid, 4, l2x, l2y, l2z))
    {
        if(gCarLock[linkcar2] == 1)
        {
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has unlocked their vehicle.");
            else format(string, sizeof(string), "* %s has unlocked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            UnLockCar(linkcar2);
        }
        else
        {
            if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
            else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            LockCar(linkcar2);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "   You are too far away from your vehicle !");
        return 1;
    }
    return 1;
}
Brackets...
Yeah, that worked! <3