How do I save Neon Lights on vehicles? -
aaronwelsh - 02.01.2013
Hello!
I have made a simple neon cmd that adds neon type lights at the bottom of the vehicle.
My problem is that they do not save; when you close the console or vehicles reload they're removed from the vehicle.
Here is my code:
pawn Code:
CMD:addneon(playerid, params[])
{
new neon1 = CreateObject(18648,0,0,0,0,0,0,100.0);
new neon2 = CreateObject(18648,0,0,0,0,0,0,100.0);
if(PlayerInfo[playerid][pAdmin] < 3)
{
return SendClientMessageEx(playerid, COLOR_RED, "You do not have permission to use this cmd.");
}
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not in a vehicle.");
AttachObjectToVehicle(neon1, GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(neon2,GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0xFFFFFFFF, "Neon lights have been installed to the vehicle..");
return 1;
}
I need help with making these neon's save. Thanks for any help.
I am also new with Pawno so no bullying!
Regards,
Aaron.
Re: How do I save Neon Lights on vehicles? -
mrtms - 02.01.2013
How do your vehicles save? Do they save in files or in a MySQL table?
If it's MySQL give us your table structure.
If it's files give us the format/example of how it looks.
Re: How do I save Neon Lights on vehicles? -
Threshold - 02.01.2013
Try this:
pawn Code:
new Neon1[MAX_VEHICLES]; //Used for the neon object
new Neon2[MAX_VEHICLES]; //Used for the second neon object
new NeonAttached[MAX_VEHICLES]; //Used to set whether a car has neon attached or not
public OnVehicleSpawn(vehicleid)
{
if(NeonAttached[vehicleid] == 1) //If the vehicle has neon attached
{
AttachObjectToVehicle(Neon1[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(Neon2[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
}
return 1;
}
CMD:addneon(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessageEx(playerid, COLOR_RED, "You do not have permission to use this cmd.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not in a vehicle as a driver.");
if(NeonAttached[GetPlayerVehicleID(playerid)] == 1) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already has neon attached, use /removeneon to remove it.");
new vehicleid = GetPlayerVehicleID(playerid);
Neon1[vehicleid] = CreateObject(18648,0,0,0,0,0,0,100.0); //Create the first neon object
Neon2[vehicleid] = CreateObject(18648,0,0,0,0,0,0,100.0); //Create the second neon object
AttachObjectToVehicle(Neon1[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(Neon2[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0xFFFFFFFF, "Neon lights have been installed on this vehicle..");
NeonAttached[vehicleid] = 1; //This vehicle has neon attached
return 1;
}
CMD:removeneon(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessageEx(playerid, COLOR_RED, "You do not have permission to use this cmd.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not in a vehicle as a driver.");
if(NeonAttached[GetPlayerVehicleID(playerid)] == 0) return SendClientMessage(playerid, COLOR_GREY, "This vehicle doesn't have neon attached, use /addneon to add it.");
new vehicleid = GetPlayerVehicleID(playerid);
DestroyObject(Neon1[vehicleid]);
DestroyObject(Neon2[vehicleid]);
SendClientMessage(playerid, 0xFFFFFFFF, "Neon lights have been removed from this vehicle..");
NeonAttached[vehicleid] = 0; //This vehicle no longer has neon attached
return 1;
}