Static Vehicle System error.
#1

I have a little problem with my in script vehicle system. In my roleplay game, I have nearly 520 faction cars. Their ID's are starting from 3 and ends at 512. So when a player buys a car, there isn't a problem for first two vehicle for their ID. But after 3rd vehicle, codes mixing and player writes /v buy, game creates a vehicle for player at SF Docks, at the same time code makes that player owner of the NG Patrol Car because that car's ID is already 3. So when player writes /stats, he sees he have a NG Patrol car. And that car which created at SF Docks, waits for that player and /v park it. Then everything turns normal. Also when a player sells his car, code mixes again and all cars mixing up.

I also tried to add a loop on the code which cheks the vehicle ID and if it's below 520, use "continue;" but it changed nothing.

Here's the loop

Код:
#define CreateVehicle S_CreateVehicle 

stock S_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay) 
{ 
    new v; 
    for(v = 0; v < MAX_VEHICLES; v++) 
    { 
        if(v < 520) continue; 
        break; 
    } 
    CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay); 
    return v; 
}
Reply
#2

Try this solution

PHP код:

#define CreateVehicle S_CreateVehicle 
stock S_CreateVehicle(modelidFloat:xFloat:yFloat:zFloat:anglecolor1color2respawn_delay

    new 
v
    for(
3MAX_VEHICLESv++) 
    { 
        if(
<= 520) continue; 
        
CreateVehicle(modelidxyzanglecolor1color2respawn_delay); 
        return 
v;
    } 
    return 
0;

This will create vehicles with a minimal ID of 521.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)