Vehicle Owner Name System -
SomebodyAndMe - 24.12.2011
Hey guys,
I have a system that shows the owner name on a car:
pawn Код:
vid = House_AddVehicle(HouseID, cModel, cPaint, cComponents, cx, cy, cz, crot, Col1, Col2);
if(_:AVehicleData[vid][ZaText] != 0) Delete3DTextLabel(AVehicleData[vid][ZaText]);
new string[50];
format(string, 50, "Owner: {77FF00}%s",AVehicleData[vid][Owner]);
AVehicleData[vid][ZaText] = Create3DTextLabel(string,0xFF0000FF,cx,cy,cz,40,1);
Attach3DTextLabelToVehicle(AVehicleData[vid][ZaText],vid,0.0,0.0,0.4);
In the beginnen (OnPlayerConnect) The HouseFile_Load 's
pawn Код:
HouseFile_Load(HouseID, bool:OnlyLoadVehicles = false)
{
new file[100], File:HFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
// Setup local variables
new cModel, cPaint, components[14], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, vid, bool:VehicleClamped, cFuel = -1;
format(file, sizeof(file), HouseFile, HouseID); // Construct the complete filename for this house-file
if (fexist(file))
{
HFile = fopen(file, io_read); // Open the housefile for reading
fread(HFile, LineFromFile); // Read the first line of the file
// Set the house so it cannot be entered by anyone, except the owner (close the house)
AHouseData[HouseID][HouseOpened] = false;
// Keep reading until the end of the file is found (no more data)
while (strlen(LineFromFile) > 0)
{
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
// If OnlyLoadVehicles is "false", only load the house-data
// If OnlyLoadVehicles is "true", only load the vehicle-data
if (OnlyLoadVehicles == false)
{
// Store the proper value in the proper place
if (strcmp(ParameterName, "HouseName", false) == 0) // If the parametername is correct ("HouseName")
format(AHouseData[HouseID][HouseName], 24, ParameterValue); // Store the HouseName
if (strcmp(ParameterName, "HouseX", false) == 0) // If the parametername is correct ("HouseX")
AHouseData[HouseID][HouseX] = floatstr(ParameterValue); // Store the HouseX
if (strcmp(ParameterName, "HouseY", false) == 0) // If the parametername is correct ("HouseY")
AHouseData[HouseID][HouseY] = floatstr(ParameterValue); // Store the HouseY
if (strcmp(ParameterName, "HouseZ", false) == 0) // If the parametername is correct ("HouseZ")
AHouseData[HouseID][HouseZ] = floatstr(ParameterValue); // Store the HouseZ
if (strcmp(ParameterName, "HouseLevel", false) == 0) // If the parametername is correct ("HouseLevel")
AHouseData[HouseID][HouseLevel] = strval(ParameterValue); // Store the HouseLevel
if (strcmp(ParameterName, "HouseMaxLevel", false) == 0) // If the parametername is correct ("HouseMaxLevel")
AHouseData[HouseID][HouseMaxLevel] = strval(ParameterValue); // Store the HouseMaxLevel
if (strcmp(ParameterName, "HousePrice", false) == 0) // If the parametername is correct ("HousePrice")
AHouseData[HouseID][HousePrice] = strval(ParameterValue); // Store the HousePrice
if (strcmp(ParameterName, "Owned", false) == 0) // If the parametername is correct ("Owned")
{
if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
AHouseData[HouseID][Owned] = true; // House is owned
else
AHouseData[HouseID][Owned] = false; // House is not owned
}
if (strcmp(ParameterName, "Owner", false) == 0) // If the parametername is correct ("Owner")
// Store the Owner (Owner will hold "1" if there is no owner (empty string), done by "sscanf" I guess)
// But this doesn't matter, as the owner will never be displayed when the house is not owned by someone
format(AHouseData[HouseID][Owner], 24, ParameterValue);
if (strcmp(ParameterName, "Insurance", false) == 0) // If the parametername is correct ("Insurance")
AHouseData[HouseID][Insurance] = strval(ParameterValue); // Store the Insurance
}
else // OnlyLoadVehicles is "true", so only read the vehicle-data
{
if (strcmp(ParameterName, "[Vehicle]", false) == 0) // If the parametername is correct ("[Vehicle]")
{
// Clear all data to start a new vehicle
cModel = 0;
cPaint = 0;
cFuel = -1;
for (new i; i < 14; i++)
components[i] = 0;
}
if (strcmp(ParameterName, "VehicleModel", false) == 0) // If the parametername is correct ("VehicleModel")
cModel = strval(ParameterValue); // Store the VehicleModel
if (strcmp(ParameterName, "Fuel", false) == 0) // If the parametername is correct ("Fuel")
cFuel = strval(ParameterValue); // Store the Fuel
if (strcmp(ParameterName, "VehiclePaintJob", false) == 0) // If the parametername is correct ("VehiclePaintJob")
cPaint = strval(ParameterValue); // Store the VehiclePaintJob
if (strcmp(ParameterName, "VehicleSpoiler", false) == 0) // If the parametername is correct ("VehicleSpoiler")
components[0] = strval(ParameterValue); // Store the VehicleSpoiler
if (strcmp(ParameterName, "VehicleHood", false) == 0) // If the parametername is correct ("VehicleHood")
components[1] = strval(ParameterValue); // Store the VehicleHood
if (strcmp(ParameterName, "VehicleRoof", false) == 0) // If the parametername is correct ("VehicleRoof")
components[2] = strval(ParameterValue); // Store the VehicleRoof
if (strcmp(ParameterName, "VehicleSideSkirt", false) == 0) // If the parametername is correct ("VehicleSideSkirt")
components[3] = strval(ParameterValue); // Store the VehicleSideSkirt
if (strcmp(ParameterName, "VehicleLamps", false) == 0) // If the parametername is correct ("VehicleLamps")
components[4] = strval(ParameterValue); // Store the VehicleLamps
if (strcmp(ParameterName, "VehicleNitro", false) == 0) // If the parametername is correct ("VehicleNitro")
components[5] = strval(ParameterValue); // Store the VehicleNitro
if (strcmp(ParameterName, "VehicleExhaust", false) == 0) // If the parametername is correct ("VehicleExhaust")
components[6] = strval(ParameterValue); // Store the VehicleExhaust
if (strcmp(ParameterName, "VehicleWheels", false) == 0) // If the parametername is correct ("VehicleWheels")
components[7] = strval(ParameterValue); // Store the VehicleWheels
if (strcmp(ParameterName, "VehicleStereo", false) == 0) // If the parametername is correct ("VehicleStereo")
components[8] = strval(ParameterValue); // Store the VehicleStereo
if (strcmp(ParameterName, "VehicleHydraulics", false) == 0) // If the parametername is correct ("VehicleHydraulics")
components[9] = strval(ParameterValue); // Store the VehicleHydraulics
if (strcmp(ParameterName, "VehicleFrontBumper", false) == 0) // If the parametername is correct ("VehicleFrontBumper")
components[10] = strval(ParameterValue); // Store the VehicleFrontBumper
if (strcmp(ParameterName, "VehicleRearBumper", false) == 0) // If the parametername is correct ("VehicleRearBumper")
components[11] = strval(ParameterValue); // Store the VehicleRearBumper
if (strcmp(ParameterName, "VehicleVentRight", false) == 0) // If the parametername is correct ("VehicleVentRight")
components[12] = strval(ParameterValue); // Store the VehicleVentRight
if (strcmp(ParameterName, "VehicleVentLeft", false) == 0) // If the parametername is correct ("VehicleVentLeft")
components[13] = strval(ParameterValue); // Store the VehicleVentLeft
if (strcmp(ParameterName, "Color1", false) == 0) // If the parametername is correct ("Color1")
Col1 = strval(ParameterValue); // Store the Color1
if (strcmp(ParameterName, "Color2", false) == 0) // If the parametername is correct ("Color2")
Col2 = strval(ParameterValue); // Store the Color2
if (strcmp(ParameterName, "VehicleX", false) == 0) // If the parametername is correct ("VehicleX")
cx = floatstr(ParameterValue); // Store the VehicleX
if (strcmp(ParameterName, "VehicleY", false) == 0) // If the parametername is correct ("VehicleY")
cy = floatstr(ParameterValue); // Store the VehicleY
if (strcmp(ParameterName, "VehicleZ", false) == 0) // If the parametername is correct ("VehicleZ")
cz = floatstr(ParameterValue); // Store the VehicleZ
if (strcmp(ParameterName, "VehicleAngle", false) == 0) // If the parametername is correct ("VehicleAngle")
crot = floatstr(ParameterValue); // Store the VehicleAngle
if (strcmp(ParameterName, "Clamped", false) == 0) // If the parametername is correct ("Clamped")
{
if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
VehicleClamped = true; // Vehicle is clamped
else
VehicleClamped = false; // Vehicle is not clamped
}
if (strcmp(ParameterName, "[/Vehicle]", false) == 0) // If the parametername is correct ("[/Vehicle]")
{
// Set both colors to 1 if they are 0 AND if there is a paintjob applied
if ((Col1 == 0) && (cPaint != 0))
Col1 = 1;
if ((Col2 == 0) && (cPaint != 0))
Col2 = 1;
// The "[/Vehicle]" is found, this means that all data about this vehicle is now stored in the variables
// Now add the vehicle to the house and set it's data
vid = House_AddVehicle(HouseID, cModel, cPaint, components, cx, cy, cz, crot, Col1, Col2);
AVehicleData[vid][Clamped] = VehicleClamped;
// Also set the fuel (set it to maximum when the fuel parameter wasn't inside the file)
if (cFuel == -1)
AVehicleData[vid][Fuel] = MaxFuel;
else // If the parameter was there, store it
AVehicleData[vid][Fuel] = MaxFuel;
}
}
// Read the next line of the file
fread(HFile, LineFromFile);
}
// Check if the maximum house-level isn't 0 (when updating to the new version)
if (AHouseData[HouseID][HouseMaxLevel] == 0)
AHouseData[HouseID][HouseMaxLevel] = 10; // Set the maximum level to 10
// Close the file
fclose(HFile);
// Return if the file was read correctly
return 1;
}
else
return 0; // Return 0 if the file couldn't be read (doesn't exist)
}
But now at the moment, when I go online, I first must /park it before it shows up. But I want, when a player comes online, it directly shows up the good owner name.
pawn Код:
House_ReplaceVehicle(HouseID, CarSlot)
{
// Setup local variables
new vid, cModel, cPaint, cComponents[14], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, Float:Health, cFuel;
new panels, doors, lights, tires;
// Get the data from the already existing vehicle that was parked before
vid = AHouseData[HouseID][VehicleIDs][CarSlot];
cModel = AVehicleData[vid][Model];
cPaint = AVehicleData[vid][PaintJob];
cFuel = AVehicleData[vid][Fuel];
for (new i; i < 14; i++)
cComponents[i] = AVehicleData[vid][Components][i];
Col1 = AVehicleData[vid][Color1];
Col2 = AVehicleData[vid][Color2];
cx = AVehicleData[vid][SpawnX];
cy = AVehicleData[vid][SpawnY];
cz = AVehicleData[vid][SpawnZ];
crot = AVehicleData[vid][SpawnRot];
GetVehicleHealth(vid, Health);
GetVehicleDamageStatus(vid, panels, doors, lights, tires);
// Delete the vehicle and clear the data
Vehicle_Delete(vid);
// Create a new vehicle in the same carslot
vid = House_AddVehicle(HouseID, cModel, cPaint, cComponents, cx, cy, cz, crot, Col1, Col2); // the same as above..
if(_:AVehicleData[vid][ZaText] != 0) Delete3DTextLabel(AVehicleData[vid][ZaText]);
new string[50];
format(string, 50, "Owner: {77FF00}%s",AVehicleData[vid][Owner]);
AVehicleData[vid][ZaText] = Create3DTextLabel(string,0xFF0000FF,cx,cy,cz,40,1);
Attach3DTextLabelToVehicle(AVehicleData[vid][ZaText],vid,0.0,0.0,0.4); // till here.
// Update the fuel of the vehicle to the previous setting
AVehicleData[vid][Fuel] = cFuel;
// Update the health to what it was before and update the bodywork
SetVehicleHealth(vid, Health);
UpdateVehicleDamageStatus(vid, panels, doors, lights, tires);
return vid;
}
Someone has an idea on where to put it so it shows up when you connect?
OnPLayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
// Always allow NPC's to login without password or account
if (IsPlayerNPC(playerid))
return 1;
// Setup local variables
new Name[MAX_PLAYER_NAME], Namev[MAX_PLAYER_NAME], NewPlayerMsg[128], VIPMsg[128], HouseID;
// Setup a PVar to allow cross-script money-transfers (only from filterscript to this mainscript) and scorepoints
SetPVarInt(playerid, "PVarMoney", 0);
SetPVarInt(playerid, "PVarScore", 0);
// Get the playername
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(playerid, Namev, sizeof(Namev));
// Also store this name for the player
GetPlayerName(playerid, APlayerData[playerid][PlayerName], 24);
// Send a message to all players to let them know somebody else joined the server
// Try to load the player's datafile ("PlayerFile_Load" returns "1" is the file has been read, "0" when the file cannot be read)
if (PlayerFile_Load(playerid) == 1)
{
// Check if the player is still banned
if (APlayerData[playerid][BanTime] < gettime()) // Player ban-time is passed
ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_INPUT, TXT_DialogLoginTitle, TXT_DialogLoginMsg, TXT_DialogLoginButton1, TXT_DialogButtonCancel);
else // Player is still banned
{
ShowRemainingBanTime(playerid); // Show the remaining ban-time to the player is days, hours, minutes, seconds
Kick(playerid); // Kick the player
}
}
else
ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_INPUT, TXT_DialogRegisterTitle, TXT_DialogRegisterMsg, TXT_DialogRegisterButton1, TXT_DialogButtonCancel);
format(VIPMsg, 128, "VIP: {FF6600}%s (%i) {FFFFFF}has joined the server", Namev, playerid);
format(NewPlayerMsg, 128, TXT_PlayerJoinedServer, Name, playerid);
if (APlayerData[playerid][PlayerLevel] == 1)
{
SendClientMessageToAll(0xFFFFFFFF, VIPMsg);
}
else
{
SendClientMessageToAll(0xFFFFFFFF, NewPlayerMsg);
}
// The houses have been loaded but not the cars, so load all vehicles assigned to the player's houses
for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
{
// Get the HouseID from this slot
HouseID = APlayerData[playerid][Houses][HouseSlot];
// Check if there is a house in this slot
if (HouseID != 0)
HouseFile_Load(HouseID, true); // Load the cars of the house
}
// Speedometer setup
Speedometer_Setup(playerid);
// MissionText TextDraw setup
APlayerData[playerid][MissionText] = TextDrawCreate(320.0, 430.0, " "); // Setup the missiontext at the bottom of the screen
TextDrawAlignment(APlayerData[playerid][MissionText], 2); // Align the missiontext to the center
TextDrawUseBox(APlayerData[playerid][MissionText], 1); // Set the missiontext to display inside a box
TextDrawBoxColor(APlayerData[playerid][MissionText], 0x00000066); // Set the box color of the missiontext
// Display a message if the player hasn't accepted the rules yet
if (APlayerData[playerid][RulesRead] == false)
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You haven't accepted the {FFFF00}/rules{FF0000} yet");
return 1;
}
Someone Please help me?
Re: Vehicle Owner Name System -
SomebodyAndMe - 24.12.2011
Bump.
Sorry, AND no i'm not a vip.
Re: Vehicle Owner Name System -
SomebodyAndMe - 28.12.2011
Bump 4 days later..