Name And Not ID Car Ownership
#1

I Have a peice of code so if u buy a car it saves your id so if ur not the car owner and dont have the same id it removes you.

But i dont want it like that i want it to save your NAME and NOT (id)

Here is the code how do i edit it to save your name.

This is the code for when u bought the car

Quote:

new boughtcar;
new Float,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
GetPlayerName(playerid,buyername,24);
boughtcar = CreateVehicle(560, x+3,y,z,91.0247, -1, -1, 99999999999);
BoughtCars[boughtcar] =999;
BoughtCarsOwner[boughtcar] =playerid;
SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Taken_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have taken a Sultan from your AutoBahn");
UsedAutoRecently[playerid] += 90;
PutPlayerInVehicle(playerid, boughtcar, 0);
printf("**(CAR TAKEN)** %s(%d) has taken a Sultan from his AutoBahn",buyername,playerid);

This is the code for when you enter the car and u aint got the same id

Quote:

new string[256];
new name[256];
new playerName[24];
GetPlayerName(playerid, playerName, 24);
GetPlayerName(BoughtCarsOwner[GetPlayerVehicleID(playerid)], name, 256);
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && BoughtCars[GetPlayerVehicleID(playerid)] == 999 && playerName[playerid] != name[playerid]) {
SendClientMessage(playerid,COLOR_YELLOW,"This car has been purchased from AutoBahn. You are not the owner.");
GetPlayerName(BoughtCarsOwner[GetPlayerVehicleID(playerid)], name,sizeof(name));
format(string, sizeof(string), "This vehicle is registered to: %s",name);
SendClientMessage(playerid, COLOR_YELLOW, string);
RemovePlayerFromVehicle(playerid);

Reply
#2

No One ?
Reply
#3

i dont understand question =s
Reply
#4

You are wrong from the basis. Here

BoughtCarsOwner[boughtcar] =playerid;

you stores the playerid, but a player doesn't use forever an id. The player disconnects and that id is free for a new player. So if you stores the playerid, maybe you'll get later here

GetPlayerName(BoughtCarsOwner[GetPlayerVehicleID(playerid)], name, 256);

the name of a different player that you expected to read. If you want to be sure who is the real owner, you might use an array of strings, like

BougthCarsOwner[boughtcar][playername][24]

to store the string of the name, not the playerid. So your code needs a rewriting.
Reply
#5

Yes i know but how do i do it,
Reply
#6

So does anyone know how to do it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)