Engine system not working for groups
#1

I made a engine system for my server i got it working but when you try to start group cars it does work Its says you don't own this vehicle could somebody please help me.

PHP код:
command(engine, playerid, params[]) 
{ 
    new 
Float:hp; 
    
GetVehicleHealth(GetPlayerVehicleID(playerid), hp); 
    if(
hp > 400) 
    { 
    if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2) 
    { 
        if(
IsAnOwnedCar(GetPlayerVehicleID(playerid))) 
        { 
            new 
vehicleid = GetPlayerVehicleID(playerid); 
            new 
string[256]; 
            new 
engine, lights, alarm, doors, bonnet, boot, objective; 
            new 
PlayerVehicle = GetVehicleFileID(GetPlayerVehicleID(playerid)); 
            if(
Player[playerid][CarLinkID] == vehicleid || Player[playerid][Car2LinkID] == vehicleid || Player[playerid][Car3LinkID] == vehicleid || Vehicles[PlayerVehicle][CarGroup] == Player[playerid][Group]) 
            { 
                
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); 
                if(
Vehicles[vehicleid][Engine] == 0) 
                { 
                    
format(string, sizeof(string), "*%s reaches for their key, and places it in the ignition before turning it.", GetName(playerid)); 
                    
NearByMessage(playerid, PURPLE, string); 
                    
Player[playerid][CarEngineStatus] = 1; 
                    
SetTimer("EngineOn", 3000, false); 
                } 
                else if(
Vehicles[vehicleid][Engine] == 1) 
                { 
                    
format(string, sizeof(string), "*%s reaches for their key, and removes it from the ignition.", GetName(playerid)); 
                    
NearByMessage(playerid, PURPLE, string); 
                    
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective); 
                    
Vehicles[vehicleid][Engine] = 0; 
                } 
            } 
            else 
SendClientMessage(playerid, GREY, "You do not own this vehicle."); 
     } 
        else 
SendClientMessage(playerid, GREY, "You do not own this vehicle."); 
    } 
    else 
SendClientMessage(playerid, GREY, "You are not in a vehicle."); 
    } 
    else 
SendClientMessage(playerid, GREY, "This vehicle is broken."); 
    return 
1; 
} 
This is the command to lock a vehicle to a group so that only group members can use it
PHP код:
command(setcargroup, playerid, params[]) 
{ 
    new 
id, string[128]; 
    if(
sscanf(params, "d", id)) 
    { 
        if(
Player[playerid][AdminLevel] >= 1) 
        { 
            
SendClientMessage(playerid, WHITE, "SYNTAX: /setcargroup [group ID]"); 
        } 
    } 
    else 
    { 
        if(
Player[playerid][AdminLevel] >= 4) 
        { 
            if(
IsPlayerInAnyVehicle(playerid)) 
            { 
                if(
id >= 0 && id < MAX_GROUPS) 
                { 
                    if(
GetVehicleFileID(GetPlayerVehicleID(playerid))  == 0) 
                    { 
                        
SendClientMessage(playerid, WHITE, "That doesn't seem to be a saved vehicle."); 
                    } 
                    else 
                    { 
                        if(
id == 0) 
                        { 
                            
SendClientMessage(playerid, WHITE, "You have unlocked this vehicle."); 
                            
Vehicles[GetVehicleFileID(GetPlayerVehicleID(playerid))][CarGroup] = 0; 
                        } 
                        else 
                        { 
                            
Vehicles[GetVehicleFileID(GetPlayerVehicleID(playerid))][CarGroup] = id; 
                            
format(string, sizeof(string), "You have locked this vehicle to Group %s.", Groups[id][GroupName]); 
                            
SendClientMessage(playerid, WHITE, string); 
                            
SaveExistingVehicle(GetPlayerVehicleID(playerid)); 
                        } 
                    } 
                } 
                else 
                { 
                    
format(string, sizeof(string), "Invalid Group ID (groups vary from ID 1 to ID %d).", MAX_GROUPS); 
                    
SendClientMessage(playerid, WHITE, string); 
                } 
            } 
            else 
            { 
                
SendClientMessage(playerid, WHITE, "You're not in a valid vehicle."); 
            } 
        } 
    } 
    return 
1; 
} 
Reply
#2

bump
Reply
#3

Thats causing the problem

pawn Код:
if(IsAnOwnedCar(GetPlayerVehicleID(playerid)))
Reply
#4

Quote:
Originally Posted by Ultra-Gaming
Посмотреть сообщение
Thats causing the problem

pawn Код:
if(IsAnOwnedCar(GetPlayerVehicleID(playerid)))
Nope that is for when the car breaks down and you try to do /e
Reply


Forum Jump:


Users browsing this thread: