/ This command checks if the player is inside a vehicle that he owns and if he\'s in range of the house where the vehicle is assigned to
COMMAND:park(playerid, params[])
{
// Setup local variables
new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
// Send the command to all admins so they can see it
SendAdminText(playerid, \"/park\", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player is inside a vehicle (he must be the driver)
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Get the vehicle-id
vid = GetPlayerVehicleID(playerid);
// Get the HouseID to which this vehicle belongs
HouseID = AVehicleData[vid][belongsToHouse];
// Check if the vehicle is owned (owner-check is not really required, as another player would get kicked out very fast)
// AND it must belong to a house that the player owns
if ((AVehicleData[vid][Owned] == true) && (HouseID != 0))
{
// Check if the vehicle is in range of the house-entrance (you cannot park a vehicle further away from your house than 150m)
if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
{
// Get the player\'s position and angle
GetVehiclePos(vid, x, y, z);
GetVehicleZAngle(vid, rot);
// Save those values for the vehicle
AVehicleData[vid][spawnX] = x;
AVehicleData[vid][spawnY] = y;
AVehicleData[vid][spawnZ] = z;
AVehicleData[vid][spawnRot] = rot;
// Find the vehicle in the player\'s houses
for (new i; i < MAX_HOUSESPERPLAYER; i++)
{
// Get the HouseID of the current house
HouseID = APlayerData[playerid][Houses];
// Loop through all carslots of this house to find the vehicle-id
for (new CarSlot; CarSlot < 10; CarSlot++)
{
// Check if this carslot holds the same vehicle-id
if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid)
{
House_ReplaceVehicle(HouseID, CarSlot); // Re-create the vehicle at the same spot the player wants to park his vehicle
PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
// Turn on the engine
GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
break; // Stop the for-loop
}
}
}
// Let the player know he parked his vehicle
SendClientMessage(playerid, 0x00FF00FF, \"Leparkoltál a kocsival\");
// Save the player-file (and his houses)
PlayerFile_Save(playerid);
}
else
{
format(Msg, 128, \"{FF0000}Ház közelében kell lenned hogy le tudj parkolni\", ParkRange);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
}
else
SendClientMessage(playerid, 0xFF0000FF, \"Nem parkolhatsz le ezzel a jarmûvel,nem a tiéd\");
}
else
SendClientMessage(playerid, 0xFF0000FF, \"Nincs mit leparkolni\");
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
Tess
Dupla hozzászólás automatikusan összefûzve. ( 2012. augusztus 02. - 19:25:17 )
// Buy a vehicle and assign it to the house
Dialog_BuyCar(playerid, response, listitem)
{
// Just close the dialog if the player clicked \"Cancel\"
if(!response) return 1;
// Setup local variables
new Counter, Msg[128], cComponents[14];
// Get the HouseID
new HouseID = APlayerData[playerid][CurrentHouse];
// Loop through the entire list of buyable vehicles
for (new i; i < sizeof(ABuyableVehicles); i++)
{
// Check if the vehicle in the list has the same class as requested
if (ABuyableVehicles[VehicleClass] == APlayerData[playerid][DialogBuyVClass])
{
// Check if this is the vehicle that the player chose
if (Counter == listitem)
{
// Check if the player has enough money to afford buying this vehicle
if (APlayerData[playerid][PlayerMoney] >= (ABuyableVehicles[Price]))
{
// Add the vehicle to the house (this sets ownership and other data that\'s needed)
// The vehicles are by default created inside the hangar of KACC Military Fuels instead of near the EasterBoard Farm
House_AddVehicle(HouseID, ABuyableVehicles[CarModel], 0, cComponents, 697.0, 3342.0, 3.9, 0.0, -1, -1);
// Let the player pay for buying the vehicle
APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] - ABuyableVehicles[Price];
// Let the player know he bought a vehicle
format(Msg, 128, TXT_PlayerBoughtVehicle, ABuyableVehicles[CarName], ABuyableVehicles[Price]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustUseGetcarAndPark);
// Save the player-file (and his houses)
PlayerFile_Save(playerid);
}
else // The player has not enough money to buy this vehicle
SendClientMessage(playerid, 0xFFFFFFFF, TXT_CannotAffordVehicle);
// Stop looking for the vehicle, as it\'s found and given to the player already
return 1;
}
else // The player chose another vehicle from the same class, keep looking for another one
Counter++;
}
}
return 1;
}
Közben meg találtam és át is írtam a kordinátákat de ugyan oda spawnolja vissza