SA-MP Forums Archive
Car ownership system help. - 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: Car ownership system help. (/showthread.php?tid=211114)



Car ownership system help. - Outcast - 14.01.2011

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;
}