Function won't work
#1

I've made this function today:
pawn Код:
stock GetPlayerBusLine(playerid,line) {
new line;
new PlayerState = GetPlayerState(playerid);
if(playerState == PLAYER_STATE_PASSENGER) {
if(GetPlayerVehicleID(playerid) = Buses[0] || GetPlayerVehicleID(playerid) = Buses[1]) return line = 1;
if(GetPlayerVehicleID(playerid) = Buses[2] || GetPlayerVehicleID(playerid) = Buses[3]) return line = 2;
if(GetPlayerVehicleID(playerid) = Buses[4] || GetPlayerVehicleID(playerid) = Buses[5]) return line = 3;
if(GetPlayerVehicleID(playerid) = Buses[6] || GetPlayerVehicleID(playerid) = Buses[7]) return line = 4;
if(GetPlayerVehicleID(playerid) = Buses[8] || GetPlayerVehicleID(playerid) = Buses[9]) return line = 5;
if(GetPlayerVehicleID(playerid) = Buses[10] || GetPlayerVehicleID(playerid) = Buses[11]) return line = 6;
if(GetPlayerVehicleID(playerid) = Buses[12] || GetPlayerVehicleID(playerid) = Buses[13]) return line = 7;
if(GetPlayerVehicleID(playerid) = Buses[14] || GetPlayerVehicleID(playerid) = Buses[15]) return line = 8;
if(GetPlayerVehicleID(playerid) = Buses[16] || GetPlayerVehicleID(playerid) = Buses[17]) return line = 9;
if(GetPlayerVehicleID(playerid) = Buses[18] || GetPlayerVehicleID(playerid) = Buses[19]) return line = 10;
}
return 1;
}
But whenever I uses it,it returns me random lines.
Could anyone help me?
Thanks
Reply
#2

There is nothing wrong with that code, it returns the appropriate lines.

If that's not how you want it - tell us how you do want it.
Reply
#3

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
There is nothing wrong with that code, it returns the appropriate lines.

If that's not how you want it - tell us how you do want it.
It won't return the right line.
It always returns line #1.
Reply
#4

pawn Код:
stock GetPlayerBusLine(playerid,line) {
new line;
new PlayerState = GetPlayerState(playerid);
if(playerState == PLAYER_STATE_PASSENGER) {
if(GetPlayerVehicleID(playerid) == Buses[0] || GetPlayerVehicleID(playerid) == Buses[1]) return line = 1;
if(GetPlayerVehicleID(playerid) == Buses[2] || GetPlayerVehicleID(playerid) == Buses[3]) return line = 2;
if(GetPlayerVehicleID(playerid) == Buses[4] || GetPlayerVehicleID(playerid) == Buses[5]) return line = 3;
if(GetPlayerVehicleID(playerid) == Buses[6] || GetPlayerVehicleID(playerid) == Buses[7]) return line = 4;
if(GetPlayerVehicleID(playerid) == Buses[8] || GetPlayerVehicleID(playerid) == Buses[9]) return line = 5;
if(GetPlayerVehicleID(playerid) == Buses[10] || GetPlayerVehicleID(playerid) == Buses[11]) return line = 6;
if(GetPlayerVehicleID(playerid) == Buses[12] || GetPlayerVehicleID(playerid) == Buses[13]) return line = 7;
if(GetPlayerVehicleID(playerid) == Buses[14] || GetPlayerVehicleID(playerid) == Buses[15]) return line = 8;
if(GetPlayerVehicleID(playerid) == Buses[16] || GetPlayerVehicleID(playerid) == Buses[17]) return line = 9;
if(GetPlayerVehicleID(playerid) == Buses[18] || GetPlayerVehicleID(playerid) == Buses[19]) return line = 10;
}
return 1;
}
"==" is used to check whether the two are equal or not, whereas, "=" sets the value of thing on left as the thing on right.
Reply
#5

Quote:
Originally Posted by [DM]Kane
Посмотреть сообщение
pawn Код:
stock GetPlayerBusLine(playerid,line) {
new line;
new PlayerState = GetPlayerState(playerid);
if(playerState == PLAYER_STATE_PASSENGER) {
if(GetPlayerVehicleID(playerid) == Buses[0] || GetPlayerVehicleID(playerid) == Buses[1]) return line = 1;
if(GetPlayerVehicleID(playerid) == Buses[2] || GetPlayerVehicleID(playerid) == Buses[3]) return line = 2;
if(GetPlayerVehicleID(playerid) == Buses[4] || GetPlayerVehicleID(playerid) == Buses[5]) return line = 3;
if(GetPlayerVehicleID(playerid) == Buses[6] || GetPlayerVehicleID(playerid) == Buses[7]) return line = 4;
if(GetPlayerVehicleID(playerid) == Buses[8] || GetPlayerVehicleID(playerid) == Buses[9]) return line = 5;
if(GetPlayerVehicleID(playerid) == Buses[10] || GetPlayerVehicleID(playerid) == Buses[11]) return line = 6;
if(GetPlayerVehicleID(playerid) == Buses[12] || GetPlayerVehicleID(playerid) == Buses[13]) return line = 7;
if(GetPlayerVehicleID(playerid) == Buses[14] || GetPlayerVehicleID(playerid) == Buses[15]) return line = 8;
if(GetPlayerVehicleID(playerid) == Buses[16] || GetPlayerVehicleID(playerid) == Buses[17]) return line = 9;
if(GetPlayerVehicleID(playerid) == Buses[18] || GetPlayerVehicleID(playerid) == Buses[19]) return line = 10;
}
return 1;
}
"==" is used to check whether the two are equal or not, whereas, "=" sets the value of thing on left as the thing on right.
Thank you very much,it works now!
Reply
#6

No problem =)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)