Who knows how I can do, when a vehicle is taken from one job to another instead respawn after a few seconds.
#1

Hi guys, now me i work for a gamemode on MySQL and zcmd.
I created the job vehicle with "AddStaticVehicleEx, but i want when a car is taken from one job another few seconds to appear another job car.
The server is RPG.
And i found here a video, with how i want to make.
Video: https://www.youtube.com/watch?v=_Efn...ature=*********

AND THIS MY SCRIPT FOR TRUCK JOB:

// TRUCK
truck[1] = AddStaticVehicleEx(515,2428.4756,-2076.1519,14.5620,178.3518,43,-1,60);
truck[2] = AddStaticVehicleEx(515,2458.4954,-2077.6685,14.5670,180.5395,222,-1,60);
truck[3] = AddStaticVehicleEx(515,2468.8547,-2077.8386,14.5711,180.0827,124,-1,60);
truck[4] = AddStaticVehicleEx(515,2523.4377,-2073.3206,14.5665,177.8641,234,-1,60);
truck[5] = AddStaticVehicleEx(515,2521.7942,-2116.4023,14.5666,0.6183,252,-1,60);
truck[6] = AddStaticVehicleEx(515,2515.1521,-2116.4482,14.5664,0.1750,53,-1,60);
truck[7] = AddStaticVehicleEx(515,2502.2883,-2116.5864,14.5597,357.7580,6,-1,60);
truck[8] = AddStaticVehicleEx(515,2490.9846,-2116.6104,14.5612,359.7795,3,-1,60);
truck[9] = AddStaticVehicleEx(515,2496.7874,-2116.5796,14.5638,357.4361,6,-1,60);
truck[10] = AddStaticVehicleEx(515,2477.9758,-2116.5818,14.5604,358.7481,113,-1,60);
truck[11] = AddStaticVehicleEx(515,2472.2312,-2116.6016,14.5735,359.1072,222,-1,60);
truck[12] = AddStaticVehicleEx(515,2467.5037,-2116.6213,14.5665,359.7959,226,-1,60);
truck[13] = AddStaticVehicleEx(515,1394.7047,-2347.4336,14.5640,0.1197,252,-1,60);
truck[14] = AddStaticVehicleEx(515,1401.4509,-2347.3831,14.5668,359.2097,229,-1,60);
truck[15] = AddStaticVehicleEx(515,1408.0065,-2347.1047,14.5726,359.9834,40,-1,60);
truck[16] = AddStaticVehicleEx(515,2778.3220,2570.6011,11.7854 ,45.3040,42,-1,60);
truck[17] = AddStaticVehicleEx(515,2784.8677,2577.0254,11.7911 ,44.7744,78,-1,60);
truck[18] = AddStaticVehicleEx(515,2805.1616,2596.3269,11.7714 ,43.8595,123,-1,60);

Now i want this truck when one is taken to respawn another one like in video.
Thaks!
Reply
#2


I don't see the problem in it, you should just remove those truck[x] and put all of those 18 AddStaticVehicleEx truck spawning functions in the
pawn Код:
public OnGameModeInit()
like this:

pawn Код:
public OnGameModeInit()
{
        AddStaticVehicleEx(515,2428.4756,-2076.1519,14.5620,178.3518,43,-1,60);
        AddStaticVehicleEx(515,2458.4954,-2077.6685,14.5670,180.5395,222,-1,60);
    AddStaticVehicleEx(515,2468.8547,-2077.8386,14.5711,180.0827,124,-1,60);
    AddStaticVehicleEx(515,2523.4377,-2073.3206,14.5665,177.8641,234,-1,60);
    AddStaticVehicleEx(515,2521.7942,-2116.4023,14.5666,0.6183,252,-1,60);
    AddStaticVehicleEx(515,2515.1521,-2116.4482,14.5664,0.1750,53,-1,60);
    AddStaticVehicleEx(515,2502.2883,-2116.5864,14.5597,357.7580,6,-1,60);
    AddStaticVehicleEx(515,2490.9846,-2116.6104,14.5612,359.7795,3,-1,60);
    AddStaticVehicleEx(515,2496.7874,-2116.5796,14.5638,357.4361,6,-1,60);
    AddStaticVehicleEx(515,2477.9758,-2116.5818,14.5604,358.7481,113,-1,60);
    AddStaticVehicleEx(515,2472.2312,-2116.6016,14.5735,359.1072,222,-1,60);
    AddStaticVehicleEx(515,2467.5037,-2116.6213,14.5665,359.7959,226,-1,60);
    AddStaticVehicleEx(515,1394.7047,-2347.4336,14.5640,0.1197,252,-1,60);
    AddStaticVehicleEx(515,1401.4509,-2347.3831,14.5668,359.2097,229,-1,60);
    AddStaticVehicleEx(515,1408.0065,-2347.1047,14.5726,359.9834,40,-1,60);
    AddStaticVehicleEx(515,2778.3220,2570.6011,11.7854 ,45.3040,42,-1,60);
    AddStaticVehicleEx(515,2784.8677,2577.0254,11.7911 ,44.7744,78,-1,60);
    AddStaticVehicleEx(515,2805.1616,2596.3269,11.7714 ,43.8595,123,-1,60);
    return 1;
}
Also that last number ( in this case 60 ) marks the seconds a new truck appears after a player comes in the old truck so you can change that on the wanted value ( in the video its 30 ).
Reply
#3

Quote:
Originally Posted by RockyGamer
Посмотреть сообщение

I don't see the problem in it, you should just remove those truck[x] and put all of those 18 AddStaticVehicleEx truck spawning functions in the
pawn Код:
public OnGameModeInit()
like this:

pawn Код:
public OnGameModeInit()
{
        AddStaticVehicleEx(515,2428.4756,-2076.1519,14.5620,178.3518,43,-1,60);
        AddStaticVehicleEx(515,2458.4954,-2077.6685,14.5670,180.5395,222,-1,60);
    AddStaticVehicleEx(515,2468.8547,-2077.8386,14.5711,180.0827,124,-1,60);
    AddStaticVehicleEx(515,2523.4377,-2073.3206,14.5665,177.8641,234,-1,60);
    AddStaticVehicleEx(515,2521.7942,-2116.4023,14.5666,0.6183,252,-1,60);
    AddStaticVehicleEx(515,2515.1521,-2116.4482,14.5664,0.1750,53,-1,60);
    AddStaticVehicleEx(515,2502.2883,-2116.5864,14.5597,357.7580,6,-1,60);
    AddStaticVehicleEx(515,2490.9846,-2116.6104,14.5612,359.7795,3,-1,60);
    AddStaticVehicleEx(515,2496.7874,-2116.5796,14.5638,357.4361,6,-1,60);
    AddStaticVehicleEx(515,2477.9758,-2116.5818,14.5604,358.7481,113,-1,60);
    AddStaticVehicleEx(515,2472.2312,-2116.6016,14.5735,359.1072,222,-1,60);
    AddStaticVehicleEx(515,2467.5037,-2116.6213,14.5665,359.7959,226,-1,60);
    AddStaticVehicleEx(515,1394.7047,-2347.4336,14.5640,0.1197,252,-1,60);
    AddStaticVehicleEx(515,1401.4509,-2347.3831,14.5668,359.2097,229,-1,60);
    AddStaticVehicleEx(515,1408.0065,-2347.1047,14.5726,359.9834,40,-1,60);
    AddStaticVehicleEx(515,2778.3220,2570.6011,11.7854 ,45.3040,42,-1,60);
    AddStaticVehicleEx(515,2784.8677,2577.0254,11.7911 ,44.7744,78,-1,60);
    AddStaticVehicleEx(515,2805.1616,2596.3269,11.7714 ,43.8595,123,-1,60);
    return 1;
}
Also that last number ( in this case 60 ) marks the seconds a new truck appears after a player comes in the old truck so you can change that on the wanted value ( in the video its 30 ).
yes I understand what you say, but I want a car when the truck type is taken from her after a few seconds to appear different. With this script if you let me take a car from her only if I get out of it reappears there. I want if a car is taken to defend another there while old that I'll run mine. Because I want all players to have enough machines for the job.
Reply
#4

First of all add this on the beginning of your script ( below the includes ):

PHP код:
new trucks[18]={123456789101112131415161718};
new 
newtruck=19;
new 
Float:truckCords[][]=
{
    {
2428.4756,-2076.1519,14.5620,178.3518},
    {
2458.4954,-2077.6685,14.5670,180.5395},
    {
2468.8547,-2077.8386,14.5711,180.0827},
    {
2523.4377,-2073.3206,14.5665,177.8641},
    {
2521.7942,-2116.4023,14.5666,0.6183},
    {
2515.1521,-2116.4482,14.5664,0.1750},
    {
2502.2883,-2116.5864,14.5597,357.7580},
    {
2490.9846,-2116.6104,14.5612,359.7795},
    {
2496.7874,-2116.5796,14.5638,357.4361},
    {
2477.9758,-2116.5818,14.5604,358.7481},
    {
2472.2312,-2116.6016,14.5735,359.1072},
    {
2467.5037,-2116.6213,14.5665,359.7959},
    {
1394.7047,-2347.4336,14.5640,0.1197},
    {
1401.4509,-2347.3831,14.5668,359.2097},
    {
1408.0065,-2347.1047,14.5726,359.9834},
    {
2778.3220,2570.6011,11.7854 ,45.3040},
    {
2784.8677,2577.0254,11.7911 ,44.7744},
    {
2805.1616,2596.3269,11.7714 ,43.8595}
};
new 
truckCols[18]={43,222,124,234,252,53,6,3,6,113,222,226,252,229,40,42,78,123}; 
This will store the trucks IDs, tell you that new truck you create will be stored with ID 19 and coordinates/colors will help us later.

Then put your trucks in a beginning of OnGameModeInit but change the respawning delay to -1. You must put them in the beginning cause then they'll have right ID's assinged ( first vehicle you spawn has ID 1, second vehicle ID 2 etc. ) and change delay to -1 cause you don't want them to respawn after left unoccupied.

PHP код:
public OnGameModeInit()
{
    
AddStaticVehicleEx(515,2428.4756,-2076.1519,14.5620,178.3518,43,-1,-1); // ID: 1
    
AddStaticVehicleEx(515,2458.4954,-2077.6685,14.5670,180.5395,222,-1,-1); // ID: 2
    
AddStaticVehicleEx(515,2468.8547,-2077.8386,14.5711,180.0827,124,-1,-1); // ID: 3
    
AddStaticVehicleEx(515,2523.4377,-2073.3206,14.5665,177.8641,234,-1,-1); // ID: 4
    
AddStaticVehicleEx(515,2521.7942,-2116.4023,14.5666,0.6183,252,-1,-1); // ID: 5
    
AddStaticVehicleEx(515,2515.1521,-2116.4482,14.5664,0.1750,53,-1,-1); // ID: 6
    
AddStaticVehicleEx(515,2502.2883,-2116.5864,14.5597,357.7580,6,-1,-1); // ID: 7
    
AddStaticVehicleEx(515,2490.9846,-2116.6104,14.5612,359.7795,3,-1,-1); // ID: 8
    
AddStaticVehicleEx(515,2496.7874,-2116.5796,14.5638,357.4361,6,-1,-1); // ID: 9
    
AddStaticVehicleEx(515,2477.9758,-2116.5818,14.5604,358.7481,113,-1,-1); // ID: 10
    
AddStaticVehicleEx(515,2472.2312,-2116.6016,14.5735,359.1072,222,-1,-1); // ID: 11
    
AddStaticVehicleEx(515,2467.5037,-2116.6213,14.5665,359.7959,226,-1,-1); // ID: 12
    
AddStaticVehicleEx(515,1394.7047,-2347.4336,14.5640,0.1197,252,-1,-1); // ID: 13
    
AddStaticVehicleEx(515,1401.4509,-2347.3831,14.5668,359.2097,229,-1,-1); // ID: 14
    
AddStaticVehicleEx(515,1408.0065,-2347.1047,14.5726,359.9834,40,-1,-1); // ID: 15
    
AddStaticVehicleEx(515,2778.3220,2570.6011,11.7854 ,45.3040,42,-1,-1); // ID: 16
    
AddStaticVehicleEx(515,2784.8677,2577.0254,11.7911 ,44.7744,78,-1,-1); // ID: 17
    
AddStaticVehicleEx(515,2805.1616,2596.3269,11.7714 ,43.8595,123,-1,-1); // ID: 18
    
return 1;

Now we're going to public OnPlayerEnterVehicle() and adding a timer each time player enters a truck with ID 1-18.

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    for(new 
i=0;i<18;i++){
        if(
trucks[i]==vehicleid){ // checking if the player entered a truck
            
trucks[i] = newtruck// we're replacing the old truck's id with the new one
            
newtruck += 1// next truck will have a bigger id
            
SetTimerEx("truck"30000false"i"i); // this tells to activate "truck" timer after 30000 miliseconds ( 30 seconds ), false is for not repeating that timer and i is for the truck number so we can know the right cords and color
        
}
    }
    return 
1;

So when those 30 seconds pass we will create a new truck.

PHP код:
forward truck(i); // here we're preparing the timer called "truck"
public truck(i)
{
    
AddStaticVehicleEx(515,truckCords[i][0],truckCords[i][1],truckCords[i][2],truckCords[i][3],truckCols[i],-1,-1); // here we are putting the right trucks coordinates and color while creating it

You probably need all of this for some kind of job so you'll want to remove the truck when it gets back to a station and to do that just set a checkpoint in a station and delete the truck when it comes back with:

PHP код:
DestroyVehicle(GetPlayerVehicleID(playerid)); 
I would be really greatfull if You could +rep me if i helped.
Thank you
Reply
#5

Thank you very much man, work. +rep. Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)