Slight Issue - Need Suggestion
#1

Hello there,

I have just created a vehicle ownership system of the script I am making. Now, I have it to where a player can have three owned vehicles, and that it spawns them all when a player spawns, unfortunately it's spawning three of the vehicle, causing various bugs with the system (obviously). What should I do?

pawn Код:
forward initiatePlayerVehicles(playerid);
public initiatePlayerVehicles(playerid)
{
    format(globalstring, sizeof(globalstring), "SELECT * FROM playervehicles WHERE playerOwnerID = '%d'", pInfo[playerid][pID]);
    mysql_query(globalstring);
    mysql_store_result();
    new x;
    while(mysql_retrieve_row())
    {
        mysql_get_field("playerOwnedVehicleID", result);
        x = strval(result);
        mysql_get_field("playerVehicleModel", result);
        pvInfo[x][playerVehicleModel] = strval(result);
        mysql_get_field("playerVehicleColor1", result);
        pvInfo[x][playerVehicleColor1] = strval(result);
        mysql_get_field("playerVehicleColor2", result);
        pvInfo[x][playerVehicleColor2] = strval(result);
        mysql_get_field("playerVehicleX", result);
        pvInfo[x][playerVehiclePosition][0] = floatstr(result);
        mysql_get_field("playerVehicleY", result);
        pvInfo[x][playerVehiclePosition][1] = floatstr(result);
        mysql_get_field("playerVehicleZ", result);
        pvInfo[x][playerVehiclePosition][2] = floatstr(result);
        mysql_get_field("playerVehicleRot", result);
        pvInfo[x][playerVehicleRotation] = floatstr(result);
        mysql_get_field("playerVehicleGas", result);
        pvInfo[x][playerVehicleGas] = floatstr(result);
        mysql_get_field("playerVehicleLocked", result);
        pvInfo[x][playerVehicleLocked] = strval(result);
        mysql_get_field("playerTrunkArmour", result);
        pvInfo[x][playerTrunkArmour] = strval(result);
        mysql_get_field("playerTrunkCash", result);
        pvInfo[x][playerTrunkMoney] = strval(result);
        mysql_get_field("playerTrunkWeapon1", result);
        pvInfo[x][playerTrunkWeapon1] = strval(result);
        mysql_get_field("playerTrunkWeapon2", result);
        pvInfo[x][playerTrunkWeapon2] = strval(result);
        mysql_get_field("playerTrunkWeapon3", result);
        pvInfo[x][playerTrunkWeapon3] = strval(result);
        mysql_get_field("playerTrunkAmmo1", result);
        pvInfo[x][playerTrunkAmmo1] = strval(result);
        mysql_get_field("playerTrunkAmmo2", result);
        pvInfo[x][playerTrunkAmmo2] = strval(result);
        mysql_get_field("playerTrunkAmmo3", result);
        pvInfo[x][playerTrunkAmmo3]= strval(result);
        mysql_get_field("playerTrunkPot", result);
        pvInfo[x][playerTrunkPot] = strval(result);
        mysql_get_field("playerTrunkCocaine", result);
        pvInfo[x][playerTrunkCocaine] = strval(result);
        mysql_get_field("playerTrunkMedicalKit", result);
        pvInfo[x][playerTrunkMedicalKit] = strval(result);
        mysql_get_field("playerTrunkMaterials", result);
        pvInfo[x][playerTrunkMaterials] = strval(result);
        if(IsValidVehicle(pVehicle1[playerid]) || IsValidVehicle(pVehicle2[playerid]) || IsValidVehicle(pVehicle3[playerid])) return 0;
        else if(!IsValidVehicle(pVehicle1[playerid]) || !IsValidVehicle(pVehicle2[playerid]) || !IsValidVehicle(pVehicle3[playerid]))
        {
            if(!IsValidVehicle(pVehicle1[playerid]))
            {
                pVehicle1[playerid] = CreateVehicle(pvInfo[x][playerVehicleModel], pvInfo[x][playerVehiclePosition][0], pvInfo[x][playerVehiclePosition][1], pvInfo[x][playerVehiclePosition][2], pvInfo[x][playerVehicleRotation], pvInfo[x][playerVehicleColor1], pvInfo[x][playerVehicleColor2], 60000);
                print("Vehicle one spawned for player!");
            }
            if(!IsValidVehicle(pVehicle2[playerid]))
            {
                pVehicle2[playerid] = CreateVehicle(pvInfo[x][playerVehicleModel], pvInfo[x][playerVehiclePosition][0], pvInfo[x][playerVehiclePosition][1], pvInfo[x][playerVehiclePosition][2], pvInfo[x][playerVehicleRotation], pvInfo[x][playerVehicleColor1], pvInfo[x][playerVehicleColor2], 60000);
                print("Vehicle two spawned for player!");
            }
            if(!IsValidVehicle(pVehicle3[playerid]))
            {
                pVehicle3[playerid] = CreateVehicle(pvInfo[x][playerVehicleModel], pvInfo[x][playerVehiclePosition][0], pvInfo[x][playerVehiclePosition][1], pvInfo[x][playerVehiclePosition][2], pvInfo[x][playerVehicleRotation], pvInfo[x][playerVehicleColor1], pvInfo[x][playerVehicleColor2], 60000);
                print("Vehicle three spawned for player!");
            }
            if(pvInfo[x][playerVehicleLocked] == 1)
            {
                SetVehicleParamsEx(x, engine, lights, alarm, 1, bonnet, boot, objective);
            }
        }
    }
    mysql_free_result();
    return 1;
}
Reply


Messages In This Thread
Slight Issue - Need Suggestion - by nmader - 15.01.2014, 18:40

Forum Jump:


Users browsing this thread: 1 Guest(s)