09.02.2013, 19:37
(
Последний раз редактировалось Phil_Cutcliffe; 10.02.2013 в 02:13.
Причина: SHOWING ORIGINAL CODE AT BOTTOM OF POST
)
Ok so I just want it so this command checks if the PLAYER_NAME trying to use the command is = to the VEHICLEID's OWNER_NAME
The vehicles are stored in scriptfiles in avs in cars
They get saved as 1, 2, 3, 4, etc (each vehicles ID)
In the file is a line that sais..
Owner=Tyrone_Badman (just an example)
Here is the code...
This is the line I put into the code trying to get it to work but failed.. Not sure how to write it!
Any help on this would be muchly appreciated! I haven't been coding long so sometimes I'm not too sure how to write something that I think of!
EDIT: EDIT: EDIT: EDIT: EDIT:
This is the original code but was not working.. We didn't notice as first but I came in day today and was unable to use my vehicle with /vlock it said I did not have the keys
EDIT EDIT EDIT 2
Here is the GetPlayerVehicleAccess (might be something wrong here instead)
The vehicles are stored in scriptfiles in avs in cars
They get saved as 1, 2, 3, 4, etc (each vehicles ID)
In the file is a line that sais..
Owner=Tyrone_Badman (just an example)
Here is the code...
Код:
CMD:vlock(playerid, params[]) { new vehicleid; if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { vehicleid = GetPlayerVehicleID(playerid); } else { vehicleid = GetClosestVehicle(playerid); if(!PlayerToVehicle(playerid, vehicleid, 5.0)) vehicleid = 0; } if(!vehicleid) return SendClientMessage(playerid, COLOR_RED, "You are not close to a vehicle!"); new id = GetVehicleID(vehicleid); if(!IsValidVehicle(id)) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!"); if(strcmp(PlayerName(playerid)) == VehicleOwner[vehicleid]) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!"); new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); if(doors == 1) { doors = 0; VehicleLock[id] = 0; GameTextForPlayer(playerid, "~g~doors unlocked", 3000, 6); } else { doors = 1; VehicleLock[id] = 1; GameTextForPlayer(playerid, "~r~doors locked", 3000, 6); } SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); SaveVehicle(id); return 1; }
Код:
if(strcmp(PlayerName(playerid)) == VehicleOwner[vehicleid])
EDIT: EDIT: EDIT: EDIT: EDIT:
This is the original code but was not working.. We didn't notice as first but I came in day today and was unable to use my vehicle with /vlock it said I did not have the keys
Код:
CMD:vlock(playerid, params[]) { new vehicleid; if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { vehicleid = GetPlayerVehicleID(playerid); } else { vehicleid = GetClosestVehicle(playerid); if(!PlayerToVehicle(playerid, vehicleid, 5.0)) vehicleid = 0; } if(!vehicleid) return SendClientMessage(playerid, COLOR_RED, "You are not close to a vehicle!"); new id = GetVehicleID(vehicleid); if(!IsValidVehicle(id)) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!"); if(GetPlayerVehicleAccess(playerid, id) < 2) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!"); new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); if(doors == 1) { doors = 0; VehicleLock[id] = 0; GameTextForPlayer(playerid, "~g~doors unlocked", 3000, 6); } else { doors = 1; VehicleLock[id] = 1; GameTextForPlayer(playerid, "~r~doors locked", 3000, 6); } SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); SaveVehicle(id); return 1; }
Here is the GetPlayerVehicleAccess (might be something wrong here instead)
Код:
GetPlayerVehicleAccess(playerid, vehicleid) { if(IsValidVehicle(vehicleid)) { if(VehicleCreated[vehicleid] == VEHICLE_DEALERSHIP) { if(IsAdmin(playerid, 1)) { return 1; } } else if(VehicleCreated[vehicleid] == VEHICLE_PLAYER) { if(strcmp(VehicleOwner[vehicleid], PlayerName(playerid)) == 0) { return 2; } else if(GetPVarInt(playerid, "CarKeys") == vehicleid) { return 1; } } } else { return 1; } return 0; }