little help please, thaaanks.
#1

PHP код:
vehOnPlayerDisconnect(playeridreason) {
    
#pragma unused reason
    
DestroyProgressBar(Bar:GetPVarInt(playerid,"FuelBar"));
    
TextDrawDestroy(Text:GetPVarInt(playerid"SpeedDraw"));
    
TextDrawDestroy(Text:GetPVarInt(playerid"VehDraw"));
    
TextDrawDestroy(Text:GetPVarInt(playerid"VehMileDraw"));
    
    new 
lcar = -1;
    if(
IsPlayerInAnyVehicle(playerid)) {
        new 
carid GetPlayerVehicleID(playerid);
        new 
= -1;
        new 
index = -1;
        if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
            while((
findPlayerCar(playerid, ++index)) != -1) {
                if(
== carid) {
                    
lcar index;
                    break;
                }
            }
        }
    }
    
format(querysizeof(query), "UPDATE `characters` SET `lastcar` = %d WHERE `id` = %d",lcar,GetPVarInt(playerid"CharID"));
    
mysql_function_query(g_mysql_handlequerytrue"EmptyCallback""");
    for(new 
i=0;i<sizeof(VehicleInfo);i++) {
        if(
VehicleInfo[i][EVOwner] == playerid && VehicleInfo[i][EVType] == EVehicleType_Owned) {
            
VehicleInfo[i][EVKeyDupe] == 0;
            
saveVehicle(i);
            
VehicleInfo[i][EVType] = EVehicleType_Uninit;
            
clearTrunk(i);
            
DestroyVehicleToys(i0);
            
DestroyVehicle(i);
        }
    }
    if(
GetPVarType(playerid"JobCar") != PLAYER_VARTYPE_NONE) {
        new 
jobcar GetPVarInt(playerid"JobCar");
        
DestroyVehicle(jobcar);
    }
    
DestroyAllRentCars(playerid);

Hey is it possible to set a timer here.. like when a player disconnects it doesn't destroyvehicle straight away but after like 1 hour or so..
Reply
#2

Yes, its possible using SetTimerEx.


PHP код:
vehOnPlayerDisconnect(playeridreason) { 
    
#pragma unused reason 
    
DestroyProgressBar(Bar:GetPVarInt(playerid,"FuelBar")); 
    
TextDrawDestroy(Text:GetPVarInt(playerid"SpeedDraw")); 
    
TextDrawDestroy(Text:GetPVarInt(playerid"VehDraw")); 
    
TextDrawDestroy(Text:GetPVarInt(playerid"VehMileDraw")); 
     
    new 
lcar = -1
    if(
IsPlayerInAnyVehicle(playerid)) { 
        new 
carid GetPlayerVehicleID(playerid); 
        new 
= -1
        new 
index = -1
        if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { 
            while((
findPlayerCar(playerid, ++index)) != -1) { 
                if(
== carid) { 
                    
lcar index
                    break; 
                } 
            } 
        } 
    } 
    
format(querysizeof(query), "UPDATE `characters` SET `lastcar` = %d WHERE `id` = %d",lcar,GetPVarInt(playerid"CharID")); 
    
mysql_function_query(g_mysql_handlequerytrue"EmptyCallback"""); 
   
SetTimerEx("DestroyPlayerVehicles"3600000false"i"playerid);



PHP код:
forward DestroyPlayerVehicles(playerid);
public 
DestroyPlayerVehicles(playerid)
{
for(new 
i=0;i<sizeof(VehicleInfo);i++) { 
        if(
VehicleInfo[i][EVOwner] == playerid && VehicleInfo[i][EVType] == EVehicleType_Owned) { 
            
VehicleInfo[i][EVKeyDupe] == 0
            
saveVehicle(i); 
            
VehicleInfo[i][EVType] = EVehicleType_Uninit
            
clearTrunk(i); 
            
DestroyVehicleToys(i0); 
            
DestroyVehicle(i); 
        } 
    } 
    if(
GetPVarType(playerid"JobCar") != PLAYER_VARTYPE_NONE) { 
        new 
jobcar GetPVarInt(playerid"JobCar"); 
        
DestroyVehicle(jobcar); 
    } 
    
DestroyAllRentCars(playerid); 
return 
1;

Untested!
Reply
#3

That didn't work.. it still destroys the vehicle on player disconnect..
Reply
#4

Quote:
Originally Posted by Debjit
Посмотреть сообщение
Yes, its possible using SetTimerEx.


PHP код:
vehOnPlayerDisconnect(playeridreason) { 
    
#pragma unused reason 
    
DestroyProgressBar(Bar:GetPVarInt(playerid,"FuelBar")); 
    
TextDrawDestroy(Text:GetPVarInt(playerid"SpeedDraw")); 
    
TextDrawDestroy(Text:GetPVarInt(playerid"VehDraw")); 
    
TextDrawDestroy(Text:GetPVarInt(playerid"VehMileDraw")); 
     
    new 
lcar = -1
    if(
IsPlayerInAnyVehicle(playerid)) { 
        new 
carid GetPlayerVehicleID(playerid); 
        new 
= -1
        new 
index = -1
        if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { 
            while((
findPlayerCar(playerid, ++index)) != -1) { 
                if(
== carid) { 
                    
lcar index
                    break; 
                } 
            } 
        } 
    } 
    
format(querysizeof(query), "UPDATE `characters` SET `lastcar` = %d WHERE `id` = %d",lcar,GetPVarInt(playerid"CharID")); 
    
mysql_function_query(g_mysql_handlequerytrue"EmptyCallback"""); 
   
SetTimerEx("DestroyPlayerVehicles"3600000false"i"playerid);



PHP код:
forward DestroyPlayerVehicles(playerid);
public 
DestroyPlayerVehicles(playerid)
{
for(new 
i=0;i<sizeof(VehicleInfo);i++) { 
        if(
VehicleInfo[i][EVOwner] == playerid && VehicleInfo[i][EVType] == EVehicleType_Owned) { 
            
VehicleInfo[i][EVKeyDupe] == 0
            
saveVehicle(i); 
            
VehicleInfo[i][EVType] = EVehicleType_Uninit
            
clearTrunk(i); 
            
DestroyVehicleToys(i0); 
            
DestroyVehicle(i); 
        } 
    } 
    if(
GetPVarType(playerid"JobCar") != PLAYER_VARTYPE_NONE) { 
        new 
jobcar GetPVarInt(playerid"JobCar"); 
        
DestroyVehicle(jobcar); 
    } 
    
DestroyAllRentCars(playerid); 
return 
1;

Untested!
What shit is this? How you get a player variable with the player disconnected?

@TOPIC

You can use a timer to destroy the vehicleid, but you can't use player informations, because his is disconnected.
Or you can save the player informations and call a timer where you use it, and destroy de vehicle.

Example of the first option:
PHP код:
//call the timer in OnPlayerDisconnect
SetTimerEx("DestroyPlayerVehicle"3600000false"i"vehicleid);
forward DestroyPlayerVehicle(vehicleid);
public 
DestroyPlayerVehicle(vehicleid)
    
DestroyVehicle(vehicleid); 
Reply
#5

Quote:
Originally Posted by Bruno13
Посмотреть сообщение
What shit is this? How you get a player variable with the player disconnected?

@TOPIC

You can use a timer to destroy the vehicleid, but you can't use player informations, because his is disconnected.
Or you can save the player informations and call a timer where you use it, and destroy de vehicle.

Example of the first option:
PHP код:
//call the timer in OnPlayerDisconnect
SetTimerEx("DestroyPlayerVehicle"3600000false"i"vehicleid);
forward DestroyPlayerVehicle(vehicleid);
public 
DestroyPlayerVehicle(vehicleid)
    
DestroyVehicle(vehicleid); 
oh shit! yeah i forgot that and i was about to edit the post, then i saw your reply.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)