Code won't work.
#1

Why isn't this peice of code kicking a player out of the car if they are not the vehicle owner?


Код:
new string[256];
  if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && BoughtCars[GetPlayerVehicleID(playerid)] == 999 && BoughtCarsOwner[GetPlayerVehicleID(playerid)] != playerid) {
	SendClientMessage(playerid,COLOR_YELLOW,"This car has been purchased from AutoBahn. You are not the owner");
	format(string, sizeof(string), "This vehicle is registered to playerid: %d",BoughtCarsOwner[GetPlayerVehicleID(playerid)]);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	RemovePlayerFromVehicle(playerid);
	return 1;
}
Heres the buying car store

Код:
new buyername[24];
GetPlayerName(playerid,buyername, 24);
if(dialogid == GROTTI_DIALOG)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <= 39999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Sultan car ($40000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(560, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Sultan vehicle from AutoBahn for $40000");
GivePlayerMoney(playerid,-40000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Sultan car from AutoBahn ($40000)",buyername,playerid);
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) <= 59999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Elegy car ($60000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(562, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Elegy vehicle from AutoBahn for $60000");
GivePlayerMoney(playerid,-60000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Elegy car from AutoBahn ($60000)",buyername,playerid);
}
if(listitem==2)
{
if(GetPlayerMoney(playerid) <= 79999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Jester car ($80000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(559, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Jester vehicle from AutoBahn for $80000");
GivePlayerMoney(playerid,-80000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Jester car from AutoBahn ($80000)",buyername,playerid);
}
if(listitem==3)
{
if(GetPlayerMoney(playerid) <= 99999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Cheetah car ($100000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(415, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Cheetah vehicle from AutoBahn for $100000");
GivePlayerMoney(playerid,-100000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Cheetah car from AutoBahn ($100000)",buyername,playerid);
}
if(listitem==4)
{
if(GetPlayerMoney(playerid) <= 119999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Turismo car ($120000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(451, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Turismo vehicle from AutoBahn for $120000");
GivePlayerMoney(playerid,-120000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Turismo car from AutoBahn ($120000)",buyername,playerid);
}
if(listitem==5)
{
if(GetPlayerMoney(playerid) <= 139999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Infernus vehicle ($140000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(411, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Infernus vehicle from AutoBahn for $140000");
GivePlayerMoney(playerid,-140000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Infernus vehicle from AutoBahn ($140000)",buyername,playerid);
}
if(listitem==6)
{
if(GetPlayerMoney(playerid) <= 139999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a NRG500 motorbike ($140000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(522, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a NRG500 motorbike from AutoBahn for $140000");
GivePlayerMoney(playerid,-140000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a NRG500 motorbike from AutoBahn ($140000)",buyername,playerid);
}
if(listitem==7)
{
if(GetPlayerMoney(playerid) <= 139999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a FCR-900 motorbike ($140000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(521, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a FCR-900 motorbike from AutoBahn for $140000");
GivePlayerMoney(playerid,-140000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a FCR-900 motorbike from AutoBahn ($140000)",buyername,playerid);
}
if(listitem==8)
{
if(GetPlayerMoney(playerid) <= 139999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Taxi ($100000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(420, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Taxi from AutoBahn for $100000");
GivePlayerMoney(playerid,-140000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Taxi from AutoBahn ($100000)",buyername,playerid);
}
if(listitem==9)
{
if(GetPlayerMoney(playerid) <= 49999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Uranus vehicle ($50000)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(558, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Uranus vehicle from AutoBahn for $50000");
GivePlayerMoney(playerid,-50000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a Uranus car from AutoBahn ($50000)",buyername,playerid);
}
if(listitem==10)
{
if(GetPlayerMoney(playerid) <= 49999) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a BMX bike ($100)");
return 1;
}
new boughtcar;
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(481, 560.4965,-1286.8813,16.9363,8.4817, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchased_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a BMX bike from AutoBahn for $100");
GivePlayerMoney(playerid,-50000);
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR PURCHASE)** %s(%d) has purchased a BMX bike from AutoBahn ($100)",buyername,playerid);
}
}
return 1;
}
Reply
#2

Anyone?
Reply


Forum Jump:


Users browsing this thread: