//somewhere on the top
new BoughtCarsOwnerName[MaxAmountOfBoughtCars][MAX_PLAYER_NAME];
//When a vehicle is bought
GetPlayername(playerid, BoughtCarsOwnerName[boughtcar]);
if(GetPlayerMoney(playerid) <= 29999) { SendClientMessage(playerid, 0xA9A9A9AA, "|_Car Purchase Failed_|"); SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Buffalo ($30000)"); return 1; } new boughtcar; new buyername[MAX_PLAYER_NAME]; GetPlayerName(playerid,buyername,sizeof(buyername)); boughtcar = CreateVehicle(402, -1985.3544,304.6387,34.9471,269.2919, -1, -1, 99999999999); BoughtCars[boughtcar] =999; strmid(BoughtCarsOwner[boughtcar], buyername, 0, strlen(buyername), MAX_PLAYER_NAME); SendClientMessage(playerid, 0xA9A9A9AA, "|_Car Purchased_|"); SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Buffalo from Wang Cars for $30000"); GivePlayerMoney(playerid,-30000); PutPlayerInVehicle(playerid, boughtcar, 0); printf("**(CAR PURCHASE)** %s(%d) has purchased a Buffalo from Wang Cars ($30000)",buyername,playerid);
new carstring[256]; if(newstate == PLAYER_STATE_DRIVER) { new vehid = GetPlayerVehicleID(playerid); if(BoughtCars[vehid] == 999) { new pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); if(strcmp(BoughtCarsOwner[vehid], pName, false)) { format(carstring, sizeof(carstring), "This vehicle has been bought by and is registered to: %s", BoughtCarsOwner[vehid]); SendClientMessage(playerid, COLOR_YELLOW, carstring); SendClientMessage(playerid, COLOR_YELLOW, "You can not drive it."); RemovePlayerFromVehicle(playerid); } } }
Код:
if(GetPlayerMoney(playerid) <= 29999) { SendClientMessage(playerid, 0xA9A9A9AA, "|_Car Purchase Failed_|"); SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Buffalo ($30000)"); return 1; } new boughtcar; new buyername[MAX_PLAYER_NAME]; GetPlayerName(playerid,buyername,sizeof(buyername)); boughtcar = CreateVehicle(402, -1985.3544,304.6387,34.9471,269.2919, -1, -1, 99999999999); BoughtCars[boughtcar] =999; strmid(BoughtCarsOwner[boughtcar], buyername, 0, strlen(buyername), MAX_PLAYER_NAME); SendClientMessage(playerid, 0xA9A9A9AA, "|_Car Purchased_|"); SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Buffalo from Wang Cars for $30000"); GivePlayerMoney(playerid,-30000); PutPlayerInVehicle(playerid, boughtcar, 0); printf("**(CAR PURCHASE)** %s(%d) has purchased a Buffalo from Wang Cars ($30000)",buyername,playerid); Код:
new carstring[256]; if(newstate == PLAYER_STATE_DRIVER) { new vehid = GetPlayerVehicleID(playerid); if(BoughtCars[vehid] == 999) { new pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); if(strcmp(BoughtCarsOwner[vehid], pName, false)) { format(carstring, sizeof(carstring), "This vehicle has been bought by and is registered to: %s", BoughtCarsOwner[vehid]); SendClientMessage(playerid, COLOR_YELLOW, carstring); SendClientMessage(playerid, COLOR_YELLOW, "You can not drive it."); RemovePlayerFromVehicle(playerid); } } } |
new BoughtCarsOwner[MAX_VEHICLES][MAX_PLAYER_NAME];
if(strcmp(BoughtCarsOwnerName[boughtcar], buyername) == 0)
You can't compare strings like that. Use strcmp.
pawn Код:
|