looping problem - 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)
+--- Thread: looping problem (
/showthread.php?tid=601342)
looping problem -
ratxrat - 20.02.2016
hayy all i have some problem with looping. i create restricted vehicle
PHP код:
if(newstate == 2)// mobpabrik
{
new CarCheck = GetPlayerVehicleID(playerid);
for (new bg = 0; bg < MAX_VEHICLES; bg++) // this looping work
if(CarCheck == bangunan[bg])
{
if(PlayerInfo[playerid][pjob] != 9)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Mobil Khusus Pegawai Bangunan");
return 1;
}
}
else
for (new por = 0; por < MAX_VEHICLES; por++) // not work just mobpabrik[0] work
if(CarCheck == mobpabrik[por])
{
if(PlayerInfo[playerid][pFaction] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Kendaraan khusus pegawai pabrik");
return 1;
}
}
else
//for (new pit = 0; pit < MAX_VEHICLES; pit++) // not work just pitsa[0] work
if(CarCheck == pitsa[pit] )
{
if(PlayerInfo[playerid][pjob] != 4)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Motor khusus Pengantar pizza");
return 1;
}
}
else
for (new cor = 0; cor < MAX_VEHICLES; cor++) // same just aray [0] work
if(CarCheck == noob[cor])
{
if(GetPlayerScore(playerid)> 2)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Motor khusus newbie");
return 1;
}
}
else
for (new Remo = 0; Remo < MAX_VEHICLES; Remo++) // this is work
if(CarCheck == Polisi[Remo])
{
new iSeat = GetPlayerVehicleSeat(playerid);
if(PlayerInfo[playerid][pFaction] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Kendaraan khusus Polisi");
return 1;
}
}
if i use this code work but i want use looping for next time i isert new car
PHP код:
if(CarCheck == mobpabrik[por]|| CarCheck == mobpabrik[1] || CarCheck == mobpabrik[2] || CarCheck == mobpabrik[3] || CarCheck == mobpabrik[4])
any solution?
Re: looping problem -
Jonggol - 20.02.2016
Try this..
pawn Код:
if(newstate == 2)
{
new CarCheck = GetPlayerVehicleID(playerid);
for (new bg; bg != MAX_VEHICLES; bg++)
{
if(CarCheck == bangunan[bg])
{
if(PlayerInfo[playerid][pjob] != 9)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Mobil Khusus Pegawai Bangunan");
}
}
if(CarCheck == mobpabrik[bg])
{
if(PlayerInfo[playerid][pFaction] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Kendaraan khusus pegawai pabrik");
}
}
if(CarCheck == pitsa[bg] )
{
if(PlayerInfo[playerid][pjob] != 4)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Motor khusus Pengantar pizza");
}
}
if(CarCheck == noob[bg])
{
if(GetPlayerScore(playerid)> 2)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Motor khusus newbie");
}
}
if(CarCheck == Polisi[bg])
{
if(PlayerInfo[playerid][pFaction] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Kendaraan khusus Polisi");
}
}
}
return 1;
}
Re: looping problem -
ratxrat - 20.02.2016
oke i will try that code dude