SA-MP Forums Archive
Function won't work - 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: Function won't work (/showthread.php?tid=252842)



Function won't work - nuriel8833 - 03.05.2011

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


Re: Function won't work - Calgon - 03.05.2011

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.


Re: Function won't work - nuriel8833 - 03.05.2011

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.


Re: Function won't work - [DM]Kane - 03.05.2011

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.


Re: Function won't work - nuriel8833 - 03.05.2011

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!


Re: Function won't work - [DM]Kane - 03.05.2011

No problem =)