12.07.2015, 19:28
I m using this script. It works fine. it removes neon when vehicle gets destroyed but i want if player quit game so neon also should be disappear. how can i make it like this? if player quit so neon should be disappear?
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)//Switch through the dialog ids..
{
case NEON_DIALOG://For dialog id NEON_DIALOG..
{
if(response)//If they click something other than cancel..
{
switch(listitem)//Switch the list items..
{
case 0://If they click blue neons..
{
if(GetPlayerMoney(playerid) >= BLUE_NEONS_PRICE)//Check if there there holding amount is more or equal to BLUE_NEONS_PRICE if so..
{
SetPVarInt(playerid, "HasBlueNeons", 1);//Set there status in a player variable..
SetPVarInt(playerid, "BlueNeons1", CreateObject(18648,0,0,0,0,0,0));//Set the neon object into a player variable..
SetPVarInt(playerid, "BlueNeons2", CreateObject(18648,0,0,0,0,0,0));//Set the neon object into a player variable..
AttachObjectToVehicle(GetPVarInt(playerid, "BlueNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
AttachObjectToVehicle(GetPVarInt(playerid, "BlueNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
GivePlayerMoney(playerid, - BLUE_NEONS_PRICE);//Remove the BLUE_NEONS_PRICE from the players holding amount..
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
new string[80];//Define our string to use later ti format BLUE_NEONS_PRICE into a string and show it in a message..
format(string, sizeof(string), "You have successfully added blue neons to your vehicle. Cost: $%d", BLUE_NEONS_PRICE);//Format the string..
SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
}
else
{
SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of BLUE_NEONS_PRICE..
}
}
case 1://If they click red neons..
{
if(GetPlayerMoney(playerid) >= RED_NEONS_PRICE)//Check if there there holding amount is more or equal to RED_NEONS_PRICE if so..
{
SetPVarInt(playerid, "HasRedNeons", 1);//Set there status in a player variable..
SetPVarInt(playerid, "RedNeons1", CreateObject(18647,0,0,0,0,0,0));//Set the neon object into a player variable..
SetPVarInt(playerid, "RedNeons2", CreateObject(18647,0,0,0,0,0,0));//Set the neon object into a player variable..
AttachObjectToVehicle(GetPVarInt(playerid, "RedNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
AttachObjectToVehicle(GetPVarInt(playerid, "RedNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
GivePlayerMoney(playerid, - RED_NEONS_PRICE);//Remove the RED_NEONS_PRICE from the players holding amount..
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
new string[80];//Define our string to use later ti format RED_NEONS_PRICE into a string and show it in a message..
format(string, sizeof(string), "You have successfully added red neons to your vehicle. Cost: $%d", RED_NEONS_PRICE);//Format the string..
SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
}
else
{
SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of RED_NEONS_PRICE..
}
}
case 2://If they click green neons..
{
if(GetPlayerMoney(playerid) >= GREEN_NEONS_PRICE)//Check if there there holding amount is more or equal to GREEN_NEONS_PRICE if so..
{
SetPVarInt(playerid, "HasGreenNeons", 1);//Set there status in a player variable..
SetPVarInt(playerid, "GreenNeons1", CreateObject(18649,0,0,0,0,0,0));//Set the neon object into a player variable..
SetPVarInt(playerid, "GreenNeons2", CreateObject(18649,0,0,0,0,0,0));//Set the neon object into a player variable..
AttachObjectToVehicle(GetPVarInt(playerid, "GreenNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
AttachObjectToVehicle(GetPVarInt(playerid, "GreenNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
GivePlayerMoney(playerid, - GREEN_NEONS_PRICE);//Remove the GREEN_NEONS_PRICE from the players holding amount..
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
new string[80];//Define our string to use later ti format GREEN_NEONS_PRICE into a string and show it in a message..
format(string, sizeof(string), "You have successfully added green neons to your vehicle. Cost: $%d", GREEN_NEONS_PRICE);//Format the string..
SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
}
else
{
SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of GREEN_NEONS_PRICE..
}
}
case 3://If they click yellow neons..
{
if(GetPlayerMoney(playerid) >= YELLOW_NEONS_PRICE)//Check if there there holding amount is more or equal to YELLOW_NEONS_PRICE if so..
{
SetPVarInt(playerid, "HasYellowNeons", 1);//Set there status in a player variable..
SetPVarInt(playerid, "YellowNeons1", CreateObject(18650,0,0,0,0,0,0));//Set the neon object into a player variable..
SetPVarInt(playerid, "YellowNeons2", CreateObject(18650,0,0,0,0,0,0));//Set the neon object into a player variable..
AttachObjectToVehicle(GetPVarInt(playerid, "YellowNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
AttachObjectToVehicle(GetPVarInt(playerid, "YellowNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
GivePlayerMoney(playerid, - YELLOW_NEONS_PRICE);//Remove the YELLOW_NEONS_PRICE from the players holding amount..
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
new string[80];//Define our string to use later ti format YELLOW_NEONS_PRICE into a string and show it in a message..
format(string, sizeof(string), "You have successfully added yellow neons to your vehicle. Cost: $%d", YELLOW_NEONS_PRICE);//Format the string..
SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
}
else
{
SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of YELLOW_NEONS_PRICE..
}
}
case 4://If they click pink neons..
{
if(GetPlayerMoney(playerid) >= PINK_NEONS_PRICE)//Check if there there holding amount is more or equal to PINK_NEONS_PRICE if so..
{
SetPVarInt(playerid, "HasPinkNeons", 1);//Set there status in a player variable..
SetPVarInt(playerid, "PinkNeons1", CreateObject(18651,0,0,0,0,0,0));//Set the neon object into a player variable..
SetPVarInt(playerid, "PinkNeons2", CreateObject(18651,0,0,0,0,0,0));//Set the neon object into a player variable..
AttachObjectToVehicle(GetPVarInt(playerid, "PinkNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
AttachObjectToVehicle(GetPVarInt(playerid, "PinkNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
GivePlayerMoney(playerid, - PINK_NEONS_PRICE);//Remove the PINK_NEONS_PRICE from the players holding amount..
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
new string[80];//Define our string to use later ti format PINK_NEONS_PRICE into a string and show it in a message..
format(string, sizeof(string), "You have successfully added pink neons to your vehicle. Cost: $%d", PINK_NEONS_PRICE);//Format the string..
SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
}
else
{
SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of PINK_NEONS_PRICE..
}
}
case 5://If they click remove neons..
{
if(GetPVarInt(playerid, "HasBlueNeons") == 1)//If they have blue neons..
{
DeletePVar(playerid, "HasBlueNeons");//Remove there status..
DestroyObject(GetPVarInt(playerid, "BlueNeons1"));//And objects..
DestroyObject(GetPVarInt(playerid, "BlueNeons2"));//And objects..
SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
}
else if(GetPVarInt(playerid, "HasRedNeons") == 1)//If they have red neons..
{
DeletePVar(playerid, "HasRedNeons");//Remove there status..
DestroyObject(GetPVarInt(playerid, "RedNeons1"));//And objects..
DestroyObject(GetPVarInt(playerid, "RedNeons2"));//And objects..
SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
}
else if(GetPVarInt(playerid, "HasGreenNeons") == 1)//If they have green neons..
{
DeletePVar(playerid, "HasGreenNeons");//Remove there status..
DestroyObject(GetPVarInt(playerid, "GreenNeons1"));//And objects..
DestroyObject(GetPVarInt(playerid, "GreenNeons2"));//And objects..
SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
}
else if(GetPVarInt(playerid, "HasYellowNeons") == 1)//If they have yellow neons..
{
DeletePVar(playerid, "HasYellowNeons");//Remove there status..
DestroyObject(GetPVarInt(playerid, "YellowNeons1"));//And objects..
DestroyObject(GetPVarInt(playerid, "YellowNeons2"));//And objects..
SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
}
else if(GetPVarInt(playerid, "HasPinkNeons") == 1)//If they have pink neons..
{
DeletePVar(playerid, "HasPinkNeons");//Remove there status..
DestroyObject(GetPVarInt(playerid, "PinkNeons1"));//And objects..
DestroyObject(GetPVarInt(playerid, "PinkNeons2"));//And objects..
SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
}
else
{
SendClientMessage(playerid, COLOUR_WHITE, "You dont have any neons to remove.");//Else they dont have any neons to remove..
}
}
}
}
}
}
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
new i;//New i which defines our playerid..
for(i = 0; i < MAX_PLAYERS; i ++)// i = 0 and is less than MAX_PLAYERS, increase 0 and loop untill you get to MAX_PLAYERS and return 1..
{
if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == vehicleid)//If the player id is connected and there vehicle id = the vehicleid that was destroyed..
{
if(GetPVarInt(i, "HasBlueNeons") == 1)//If they have blue neons..
{
DeletePVar(i, "HasBlueNeons");//Remove there status..
DestroyObject(GetPVarInt(i, "BlueNeons1"));//And objects..
DestroyObject(GetPVarInt(i, "BlueNeons2"));//And objects..
}
else if(GetPVarInt(i, "HasRedNeons") == 1)//If they have red neons..
{
DeletePVar(i, "HasRedNeons");//Remove there status..
DestroyObject(GetPVarInt(i, "RedNeons1"));//And objects..
DestroyObject(GetPVarInt(i, "RedNeons2"));//And objects..
}
else if(GetPVarInt(i, "HasGreenNeons") == 1)//If they have green neons..
{
DeletePVar(i, "HasGreenNeons");//Remove there status..
DestroyObject(GetPVarInt(i, "GreenNeons1"));//And objects..
DestroyObject(GetPVarInt(i, "GreenNeons2"));//And objects..
}
else if(GetPVarInt(i, "HasYellowNeons") == 1)//If they have yellow neons..
{
DeletePVar(i, "HasYellowNeons");//Remove there status..
DestroyObject(GetPVarInt(i, "YellowNeons1"));//And objects..
DestroyObject(GetPVarInt(i, "YellowNeons2"));//And objects..
}
else if(GetPVarInt(i, "HasPinkNeons") == 1)//If they have pink neons..
{
DeletePVar(i, "HasPinkNeons");//Remove there status..
DestroyObject(GetPVarInt(i, "PinkNeons1"));//And objects..
DestroyObject(GetPVarInt(i, "PinkNeons2"));//And objects..
}
}
}
return 1;
}