Loop should send one message but it sends two. - 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: Loop should send one message but it sends two. (
/showthread.php?tid=284194)
Loop should send one message but it sends two. -
Jack_Leslie - 18.09.2011
Hi guys.
I have this code when the players state changes from onfoot to driver:
pawn Код:
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(vehicleid == CarInfo[i][ownedvehicle])
{
new vehiclename[128];
GetVehicleName(vehicleid, vehiclename, sizeof(vehiclename));
format(string, sizeof(string), "* This %s is owned by %s.", vehiclename, CarInfo[i][vOwner]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
It works in the way that it only sends the message if the vehicleid == carinfo..
But,
sometimes it sends
"* This [car] is owned by [owner]"
"* This is owned by ."
I don't see why it would send it twice though, second time having empty variables.
Re: Loop should send one message but it sends two. -
=WoR=Varth - 18.09.2011
I'm prety sure your CarInfo variable length wrongly setted.
Anyways, just put a return or break.