• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with hotdog vendor samp
#5
(2025-03-24, 09:27 AM)Axzyl Wrote: i wanna make sure that vehicle spawns there but respawns every 5 min if its no longer in that position, that players entering any hotdog vehicle can toggle job by pressing 2 that players next to it can buy by pressing left alt. idk why its so complicated

Hello, you have a flag in your script that tells that you "own" a van but you never use it.

In function:

Code:
forward CheckVehiclePositions();
public CheckVehiclePositions()
{
    for (new i = 0; i < MAX_VENDORS; i++)
    {
         new vehicleId = GetPlayerVehicleID(g_Sellers[i]); // we are getting if seller occupied car
         if (vehicleId != 0 && g_VehicleIDs[i] == vehicleId) // if it's actually occupied and the id matches the one that was occupied we skip
         {
              continue;
         }

        // Check if the vendor vehicle exists at the spawn location
        new Float:vehX, Float:vehY, Float:vehZ;
        GetVehiclePos(g_VehicleIDs[i], vehX, vehY, vehZ);

        // If the vendor vehicle is not at the spawn location
        if (floatabs(vehX - (spawnX + (i * 3))) > 10.0 || floatabs(vehY - spawnY) > 10.0 || floatabs(vehZ - spawnZ) > 10.0) // 10 units tolerance
        {
            // Try to spawn a new vehicle if it doesn't exist at the spawn point
            new vehicleid = INVALID_VEHICLE_ID;

            // Loop through all possible vehicle IDs (vehicle IDs are indexed from 1)
            for (new vehicleIndex = 1; vehicleIndex <= MAX_VEHICLES; vehicleIndex++)
            {
                vehicleid = vehicleIndex; // Check each vehicle ID
                if (vehicleid != INVALID_VEHICLE_ID)
                {
                    new Float:checkX, Float:checkY, Float:checkZ;
                    GetVehiclePos(vehicleid, checkX, checkY, checkZ);

                    // If vehicle is within a 10-unit radius of the spawn location
                    if (floatabs(checkX - (spawnX + (i * 3))) <= 10.0 && floatabs(checkY - spawnY) <= 10.0 && floatabs(checkZ - spawnZ) <= 10.0)
                    {
                        // Vehicle is close enough, no need to respawn
                        vehicleid = INVALID_VEHICLE_ID;
                        break;
                    }
                }
            }

            // If no vehicle found at spawn point, spawn a new one
            if (vehicleid == INVALID_VEHICLE_ID)
            {
                g_VehicleIDs[i] = AddStaticVehicle(VEHICLE_MODEL_ID, spawnX + (i * 3), spawnY, spawnZ, spawnAngle, 1, 1);
                SendClientMessageToAll(COLOR_YELLOW, "A vendor vehicle has been reset to its original location!");
            }
        }
    }
    return 1;
}
  Reply


Messages In This Thread
help with hotdog vendor samp - by Axzyl - 2025-03-24, 09:02 AM
RE: help with hotdog vendor samp - by Axzyl - 2025-03-24, 09:03 AM
RE: help with hotdog vendor samp - by Axzyl - 2025-03-24, 09:27 AM
RE: help with hotdog vendor samp - by J0nathan550 - 2025-04-14, 06:09 PM
RE: help with hotdog vendor samp - by Axzyl - 2025-03-24, 09:33 AM

Forum Jump: