Okay I'm trying to create AdminCar system where admin can create some car and then when he exit's it that car will be destroyed.
pawn Код:
if(dialogid == ADMIN_CARS_DIALOG) {
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerFacingAngle(playerid, A);
GetPlayerPos(playerid,X, Y, Z);
if(Player[playerid][AdminLevel] > 0) {
if(!response) return SendClientMessage(playerid, COLOR_LIGHTRED, " You Canceled!");
if(listitem == 0) { //Buffalo
AdminCar = AddStaticVehicle(402, X+2, Y+3, Z, A, 151, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 1) { //Infernus
AdminCar = AddStaticVehicle(411, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 2) { //Cheetah
AdminCar = AddStaticVehicle(415, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 3) { //Hotknife
AdminCar = AddStaticVehicle(434, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 4) { //Turismo
AdminCar = AddStaticVehicle(451, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 5) { //Hotring Racer
AdminCar = AddStaticVehicle(494, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 6) { //Super GT
AdminCar = AddStaticVehicle(506, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 7) { //Slamvan
AdminCar = AddStaticVehicle(535, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 8) { //Bullet
AdminCar = AddStaticVehicle(541, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 9) { //Bandito
AdminCar = AddStaticVehicle(568, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 10) { //BF Injection
AdminCar = AddStaticVehicle(424, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}//BF Injection\n*Hunter\n*Monster\n*Sandking\n*NRG-500\nBandito\n*Andromada
if(listitem == 11) { //Hunter
AdminCar = AddStaticVehicle(425, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 12) { //Monster
AdminCar = AddStaticVehicle(444, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 13) { //SandKing
AdminCar = AddStaticVehicle(495, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 14) { //NRG-500
AdminCar = AddStaticVehicle(522, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 15) { //Bandito
AdminCar = AddStaticVehicle(568, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 16) { //Andromada
AdminCar = AddStaticVehicle(592, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
if(listitem == 17) { //Other dialog where you need to enter id of your vehicle!
ShowPlayerDialog(playerid, ADMIN_CARSID_DIALOG,DIALOG_STYLE_INPUT,"Vehicle ID","Please enter ID of your vehicle.","Spawn","Cancel");
}
}
}
if(dialogid == ADMIN_CARSID_DIALOG)
{
if(!response) return SendClientMessage(playerid, COLOR_LIGHTRED, " You Canceled!");
new carid = strval(inputtext);
if(!IsNumeric(inputtext)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Please use numbers as a ID of your car. [HINT]: Please use ID 400-605.");
if(carid >= 400 && carid =< 605)
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerFacingAngle(playerid, A);
GetPlayerPos(playerid,X, Y, Z);
AdminCar = AddStaticVehicle(carid, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, but we can't find a car with ID you wanted. [HINT]: Please use ID 400-605.");
}
So I've got few admins on my server and let's say that I crate Buffalo so that Buffalo will be identified like AdminCar, but when some other admin creates some X car that that X car will be AdminCar. So, when I exit my car,my car won't be destroyed.
Can anyone help me( if you understand me). :S
Well the issue is that if there is more then one admin creating vehicles, the variable stored in AdminCar is changed, erasing the old one causing any previously spawned ones not to be destroyed as you would like. A good solution to this is making AdminCar attribute it's variable to each player. An example of what should be changed is below.
Okay, thanks for understanding me and taking time to show me what to do.
Anyways, I'll try to edit my script now and try to see if it works.
And, I wanted to create something like that, but I wasn't sure how to make it, so... Thanks alot!
Glad it works at this stage.