Car system trouble.
#1

Hey there,

I'm currently running a modified version of LVRCR 1.8.

The car system on it, is flawed and I can't seem to figure out how to fix it. Basically, the problem is that when a player purchases a car, the script stores the ID of the player, instead of the playername. So here's a hypothetical situation:

Me (ID: 0) buys car.
I log out.
Someone else logs into server and becomes ID: 0.
That person now owns my car!

Can anyone help me?

Pawno (Car Command):

Код:
	if(strcmp(cmd,"/buycar",true)==0)
	{
  if(IsSpawned[playerid] == 0) {
	SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
  return 1;
  }
	//if(IsSpawned[playerid] == 1) {
	//SendClientMessage(playerid, COLOR_ERROR, "This command has been disabled due to upgrades. Check back soon");
  //return 1;
  //}
  if(Jailed[playerid] == 1) {
	SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command in jail");
  return 1;
  }
  if(!IsPlayerInCheckpoint(playerid)) {
  SendClientMessage(playerid,COLOR_ERROR,"You need to be in the checkpoint at AutoBahn to attempt to sell a car");
  return 1;
  }
  autobahnowner[playerid]=dUserINT(PlayerName(playerid)).("autobahnowner");
	if(autobahnowner[playerid] == 1337) {
	SendClientMessage(playerid,COLOR_ERROR,"You are the owner of AutoBahn. You cannot buy any vehicle from AutoBahn");
	return 1;
	}

  if(IsPlayerInCheckpoint(playerid) && getCheckpointType(playerid) == 19)
  {
  if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) {
  SendClientMessage(playerid, 0xA9A9A9AA, "|_Vehicle Purchase Failed_|");
	SendClientMessage(playerid, COLOR_ERROR, "You cannot be in a car when using this command");
  return 1;
	}
  new buyername[24];
  GetPlayerName(playerid,buyername, 24);
	new x_nr[256];
			x_nr = strtok(cmdtext, idx);
			if(!strlen(x_nr)) {
				SendClientMessage(playerid, COLOR_ERROR, "USAGE: /buycar 1-10");
   			return 1;
			}
		  if(strcmp(x_nr,"1",true) == 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);
			for(new i=0;i<MAX_PLAYERS;i++)
			{
			if(IsPlayerConnected(i))
			{
				  autobahnowner[i]=dUserINT(PlayerName(i)).("autobahnowner");
			if(autobahnowner[i] == 1337)
			{
				new autoowner[24];
				GetPlayerName(i,autoowner,24);
				SendClientMessage(i, 0xA9A9A9AA, "|_Vehicle Sold_|");
				format(string, sizeof(string), "AutoBahn salesmen have sold a Sultan vehicle to %s(%d) - You receive $40000",buyername,playerid);
  			SendClientMessage(i, 0x00C7FFAA, string);
			  SendClientMessage(i, 0x00C7FFAA, "You can sell the AutoBahn business to a player using /sellautobahn (id)");
			  GivePlayerMoney(i,40000);
			  printf("**(CAR PURCHASE CASH)** AutoBahn owner %s(%d) has received $40000 from a Sultan car sale",autoowner,i);
			}
			}
			}
			}
			else if(strcmp(x_nr,"2",true) == 0)
			{
        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, 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 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);
			for(new i=0;i<MAX_PLAYERS;i++)
			{
			if(IsPlayerConnected(i))
			{
				  autobahnowner[i]=dUserINT(PlayerName(i)).("autobahnowner");
			if(autobahnowner[i] == 1337)
			{
			  new autoowner[24];
				GetPlayerName(i,autoowner,24);
				SendClientMessage(i, 0xA9A9A9AA, "|_Vehicle Sold_|");
				format(string, sizeof(string), "AutoBahn salesmen have sold a Elegy vehicle to %s(%d) - You receive $60000",buyername,playerid);
  			SendClientMessage(i, 0x00C7FFAA, string);
			  SendClientMessage(i, 0x00C7FFAA, "You can sell the AutoBahn business to a player using /sellautobahn (id)");
			  GivePlayerMoney(i,60000);
			  printf("**(CAR PURCHASE CASH)** AutoBahn owner %s(%d) has received $60000 from a Elegy car sale",autoowner,i);
			}
			}
			}
			}
All the way to 10... etc...

Pawno (Message):

Код:
  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;
Reply


Messages In This Thread
Car system trouble. - by bdee - 23.02.2009, 16:37
Re: Car system trouble. - by bdee - 24.02.2009, 00:15
Re: Car system trouble. - by Pghpunkid - 24.02.2009, 00:29
Re: Car system trouble. - by Byrner - 09.03.2009, 17:30
Re: Car system trouble. - by MenaceX^ - 09.03.2009, 18:04
Re: Car system trouble. - by bdee - 09.03.2009, 20:30
Re: Car system trouble. - by Byrner - 09.03.2009, 20:34

Forum Jump:


Users browsing this thread: 1 Guest(s)