14.01.2011, 16:36
Well, I made it when a player types /buycar a car is created. A number of the car (1 digit for testing purpose) is saved in the vehicles/#.json file and to the user file of the user who bought it. When a player gets in a car he get's spammed with messages "This is not your car". If he enters in his car, he gets a message "Welcome to your car" and rest of the messages is "This is not your car". This is because of the loop. How can I fix that?
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i < OWNED_CARS_COUNT; i ++)
{
new pname[MAX_PLAYER_NAME], ppath[50];
GetPlayerName(playerid, pname, sizeof(pname));
format(ppath, sizeof(ppath), "users/%s.json", pname);
if(i == djInt(ppath, "vehicle/ID") && djInt("vehicles/2.json", "player/owner") == i)
{
SendClientMessage(playerid, 0x355262, "Welcome to your vehicle");
}
else
{
SendClientMessage(playerid, 0x355262, "THIS AIN'T YOUR FUCKING CAR! !1111");
}
}
return 1;
}