19.11.2010, 10:05
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
for(new a = 0; a < sizeof(COwnerData); i++)
{
/* I assume you place all the owned vehicles in an array ?
For example COwnerData[i][VehicleID] = CreateVehicle(..)
This is needed or you won't be able to find the vehicleid
from the index, you will need to do this under OnFilterScrit/GameModeInit
Upon every sucessfull load of a file, using sscanf is a good idea for lots of data
*/
if(COwnerData[i][VehicleID] == vehicleid)
{
if(!strcmp(PlayerName, COwnerData[i][CarOwner], false))
{
SendClientMessage(playerid, COLOR_WHITE, "This is your vehicle, bro!");
return 1;
}
// Here is if the vehicleid is a owned vehicle and not the players.
// It would be bes to only create owned vehicles and not, not-owned vehicles
// It then would be much easier to find if the vehicle is owned or not.
// Assuming you have vehicles that are not owned aswell
// I will use as an example, that CarOwner is named "none" if nobody owns it.
// You will have to use an extra strcmp check if you have un owned and owned vehicles.
if(strcmp(COwnerData[i][CarOwner], "none", true))
{
SendClientMessage(playerid, COLOR_WHITE, "This vehicle is owned because the owners name was not NONE.");
return 1;
}
// Remember to ban the name none, this is why I recommend only having brought vehicles! :D
// Otherwise, if you do use my method, only having brought vehicles, so there are no for-sale vehicles
// Simply do not use the none strcmp check and place this directly under the closing bracket after the first STRCMP.
return SendClientMessage(playerid, COLOR_WHITE, "Y0 dawg, stup strealinz shitz");
}
// The vehicle is not a ownership vehicle because the vehicleid was not inserted into the array
}
return 1;
}