Why isn't it working?
#1

The title says it all...only works for tempvar == 7
pawn Код:
new tempvar =0;
    if(clickedid == Otto)
    {
        if(tempvar == 0)
        {
            InterpolateCameraPos(playerid, -1656.097045, 1213.755859, 10.032490, -1661.531860, 1216.964111, 15.707123, 3000);
            InterpolateCameraLookAt(playerid, -1659.603271, 1214.037231, 9.126958, -1664.103149, 1221.066528, 14.458753, 3000);
            tempvar =1;
        }
        if(tempvar == 1)
        {
            InterpolateCameraPos(playerid, -1661.531860, 1216.964111, 15.707123, -1671.581176, 1209.734741, 16.275499, 3000);
            InterpolateCameraLookAt(playerid, -1664.311889, 1220.928100, 14.458752, -1675.642822, 1207.708740, 14.178371, 3000);
            tempvar = 2;
        }
        if(tempvar == 2)
        {
            InterpolateCameraPos(playerid, -1671.581176, 1209.734741, 16.275499, -1652.179443, 1213.186035, 15.364459, 3000);
            InterpolateCameraLookAt(playerid, -1675.757080, 1207.820434, 14.303216, -1656.888061, 1213.737548, 13.775321, 3000);
            tempvar = tempvar +1;
        }
        if(tempvar == 3)
        {
            InterpolateCameraPos(playerid, -1652.179443, 1213.186035, 15.364459, -1654.101684, 1207.964599, 15.218760, 5000);
            InterpolateCameraLookAt(playerid, -1656.944946, 1213.746093, 13.957931, -1649.343017, 1207.577148, 13.733697, 5000);
            tempvar = tempvar +1;
        }
        if(tempvar == 4)
        {
            InterpolateCameraPos(playerid, -1654.101684, 1207.964599, 15.218760, -1672.264770, 1211.428833, 23.663595, 3000);
            InterpolateCameraLookAt(playerid, -1649.279663, 1207.730834, 13.917510, -1676.010864, 1208.806396, 21.641214, 3000);
            tempvar = tempvar +1;
        }
        if(tempvar == 5)
        {
            InterpolateCameraPos(playerid, -1672.264770, 1211.428833, 23.663595, -1654.091064, 1212.976928, 22.535552, 3000);
            InterpolateCameraLookAt(playerid, -1675.861450, 1208.540039, 21.739759, -1651.202148, 1209.022583, 21.526897, 3000);
            tempvar = tempvar +1;
        }
        if(tempvar == 6)
        {
            InterpolateCameraPos(playerid, -1654.091064, 1212.976928, 22.535552, -1657.560668, 1209.979125, 22.267757, 3000);
            InterpolateCameraLookAt(playerid, -1651.262573, 1209.015136, 21.393383, -1661.098754, 1206.738159, 20.861221, 3000);
            tempvar = tempvar +1;
        }
        if(tempvar == 7)
        {
            InterpolateCameraPos(playerid, -1657.560668, 1209.979125, 22.267757, -1663.856323, 1217.107666, 22.857522, 3000);
            InterpolateCameraLookAt(playerid, -1660.987426, 1206.770385, 20.549652, -1665.108520, 1221.784545, 21.609153, 3000);
            tempvar = tempvar +1;
        }
    }
    return 1;
}
Reply
#2

You are changing the value of tempvar into each one of the if clauses, so when it goes into the first if, it takes the value 1, so it gets into the second if clause, and that repeats until it finishes with all if clauses.

The solution to this problem would be using else if clauses or just a switch.
Reply
#3

Now it only goes from the first vehicle to second,it does the same each time i click it. Why?
pawn Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    new tempvar =0;
    if(clickedid == Otto)
    {
        if(tempvar == 0)
        {
            InterpolateCameraPos(playerid, -1656.097045, 1213.755859, 10.032490, -1661.531860, 1216.964111, 15.707123, 3000);
            InterpolateCameraLookAt(playerid, -1659.603271, 1214.037231, 9.126958, -1664.103149, 1221.066528, 14.458753, 3000);
            tempvar = tempvar +1;
        }
        else if(tempvar == 1)
        {
            InterpolateCameraPos(playerid, -1661.531860, 1216.964111, 15.707123, -1671.581176, 1209.734741, 16.275499, 3000);
            InterpolateCameraLookAt(playerid, -1664.311889, 1220.928100, 14.458752, -1675.642822, 1207.708740, 14.178371, 3000);
            tempvar = tempvar +1;
        }
        else if(tempvar == 2)
        {
            InterpolateCameraPos(playerid, -1671.581176, 1209.734741, 16.275499, -1652.179443, 1213.186035, 15.364459, 3000);
            InterpolateCameraLookAt(playerid, -1675.757080, 1207.820434, 14.303216, -1656.888061, 1213.737548, 13.775321, 3000);
            tempvar = tempvar +1;
        }
        else if(tempvar == 3)
        {
            InterpolateCameraPos(playerid, -1652.179443, 1213.186035, 15.364459, -1654.101684, 1207.964599, 15.218760, 5000);
            InterpolateCameraLookAt(playerid, -1656.944946, 1213.746093, 13.957931, -1649.343017, 1207.577148, 13.733697, 5000);
            tempvar = tempvar +1;
        }
        else if(tempvar == 4)
        {
            InterpolateCameraPos(playerid, -1654.101684, 1207.964599, 15.218760, -1672.264770, 1211.428833, 23.663595, 3000);
            InterpolateCameraLookAt(playerid, -1649.279663, 1207.730834, 13.917510, -1676.010864, 1208.806396, 21.641214, 3000);
            tempvar = tempvar +1;
        }
        else if(tempvar == 5)
        {
            InterpolateCameraPos(playerid, -1672.264770, 1211.428833, 23.663595, -1654.091064, 1212.976928, 22.535552, 3000);
            InterpolateCameraLookAt(playerid, -1675.861450, 1208.540039, 21.739759, -1651.202148, 1209.022583, 21.526897, 3000);
            tempvar = tempvar +1;
        }
        else if(tempvar == 6)
        {
            InterpolateCameraPos(playerid, -1654.091064, 1212.976928, 22.535552, -1657.560668, 1209.979125, 22.267757, 3000);
            InterpolateCameraLookAt(playerid, -1651.262573, 1209.015136, 21.393383, -1661.098754, 1206.738159, 20.861221, 3000);
            tempvar = tempvar +1;
        }
        else if(tempvar == 7)
        {
            InterpolateCameraPos(playerid, -1657.560668, 1209.979125, 22.267757, -1663.856323, 1217.107666, 22.857522, 3000);
            InterpolateCameraLookAt(playerid, -1660.987426, 1206.770385, 20.549652, -1665.108520, 1221.784545, 21.609153, 3000);
            tempvar = tempvar +1;
        }      
    }
    return 1;
}
Reply
#4

You always set tempvar to 0 when the callback is called, so you have to remove tempvar from the callback, and make it global.
Reply
#5

Quote:
Originally Posted by Xabi
Посмотреть сообщение
You always set tempvar to 0 when the callback is called, so you have to remove tempvar from the callback, and make it global.
like that, Then I equal it to 0 when it's the last one..
pawn Код:
new tempvar;
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == Otto)
    {
        if(tempvar == 0)
        {
            InterpolateCameraPos(playerid, -1656.097045, 1213.755859, 10.032490, -1661.531860, 1216.964111, 15.707123, 3000);
            InterpolateCameraLookAt(playerid, -1659.603271, 1214.037231, 9.126958, -1664.103149, 1221.066528, 14.458753, 3000);
        }
        else if(tempvar == 1)
        {
            InterpolateCameraPos(playerid, -1661.531860, 1216.964111, 15.707123, -1671.581176, 1209.734741, 16.275499, 3000);
            InterpolateCameraLookAt(playerid, -1664.311889, 1220.928100, 14.458752, -1675.642822, 1207.708740, 14.178371, 3000);
        }
        else if(tempvar == 2)
        {
            InterpolateCameraPos(playerid, -1671.581176, 1209.734741, 16.275499, -1652.179443, 1213.186035, 15.364459, 3000);
            InterpolateCameraLookAt(playerid, -1675.757080, 1207.820434, 14.303216, -1656.888061, 1213.737548, 13.775321, 3000);
        }
        else if(tempvar == 3)
        {
            InterpolateCameraPos(playerid, -1652.179443, 1213.186035, 15.364459, -1654.101684, 1207.964599, 15.218760, 5000);
            InterpolateCameraLookAt(playerid, -1656.944946, 1213.746093, 13.957931, -1649.343017, 1207.577148, 13.733697, 5000);
        }
        else if(tempvar == 4)
        {
            InterpolateCameraPos(playerid, -1654.101684, 1207.964599, 15.218760, -1672.264770, 1211.428833, 23.663595, 3000);
            InterpolateCameraLookAt(playerid, -1649.279663, 1207.730834, 13.917510, -1676.010864, 1208.806396, 21.641214, 3000);
        }
        else if(tempvar == 5)
        {
            InterpolateCameraPos(playerid, -1672.264770, 1211.428833, 23.663595, -1654.091064, 1212.976928, 22.535552, 3000);
            InterpolateCameraLookAt(playerid, -1675.861450, 1208.540039, 21.739759, -1651.202148, 1209.022583, 21.526897, 3000);
        }
        else if(tempvar == 6)
        {
            InterpolateCameraPos(playerid, -1654.091064, 1212.976928, 22.535552, -1657.560668, 1209.979125, 22.267757, 3000);
            InterpolateCameraLookAt(playerid, -1651.262573, 1209.015136, 21.393383, -1661.098754, 1206.738159, 20.861221, 3000);
        }
        else if(tempvar == 7)
        {
            InterpolateCameraPos(playerid, -1657.560668, 1209.979125, 22.267757, -1663.856323, 1217.107666, 22.857522, 3000);
            InterpolateCameraLookAt(playerid, -1660.987426, 1206.770385, 20.549652, -1665.108520, 1221.784545, 21.609153, 3000);
            tempvar = 0;
            return 1;
        }
        tempvar += 1;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)