How to save on name not playerid
#1

The lvrcr Car system is a great system (well i think) but the cars that are bought are stored on the playerid NOT the playername.


I would like to store it on the playername instead because when a player logs off and another logs in with the same ID that player now owns the car....


Heres the code::

Код:
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, 2174.2114,1421.0642,10.5913,91.0247, -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;
}
Код:
	}
	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);
	return 1;
}
I made an attempt at it and edited the code a bit. I added
Код:
 strmid(BoughtCarsOwner[boughtcar], pname, 0, strlen(pname), 255);
But now when i buy a car, it kicks me out not another player.


Please don't say ask in that topic because if any of you have seen the topic, it's inactive. People have problems but no problems are solved.
Reply
#2

Anyone?
Reply
#3

So basically what you want is a Vehicle Ownership system?
Reply
#4

Quote:
Originally Posted by Joe Torran C
So basically what you want is a Vehicle Ownership system?
Basically except the ones that are released are to complicated when it comes to what i need.



Like, all I want is someone buying a vehicle (from the shop i already created) then it saves to their name, not their playerID which what it's doing right now.

Reply
#5

Try formatting BoughtCarsOwner[boughtcar] to the player's name.
Reply
#6

Quote:
Originally Posted by biltong
Try formatting BoughtCarsOwner[boughtcar] to the player's name.
Can you show me how?


I tried this, didn't work

Код:
 strmid(BoughtCarsOwner[boughtcar], pname, 0, strlen(pname), 255);
Reply
#7

Hmmm, I just realised that formatting wouldnt work. You'd probably need a multi-dimensional variable, but I'm not sure how that would look. I'll keep thinking.
Reply
#8

Quote:
Originally Posted by biltong
Hmmm, I just realised that formatting wouldnt work. You'd probably need a multi-dimensional variable, but I'm not sure how that would look. I'll keep thinking.
Oh ok thanks man
Reply
#9

Anyone else have any ideas?
Reply
#10

I also need help with this, my users keep complaining they quit, come back and they can't use their vehicle due to their ID changing.
Reply


Forum Jump:


Users browsing this thread: