Ownership Problem!
#1

Hey Guys, i want to make a car-ownership but it doesn work even with the ground functions:

CODE...

Код:
#include <a_samp>
#include <dini>
#include <dudb>
#include <dutils>

new BCars;

new Text:VehName[sizeof(BCars)];
new Text:VehOwner[sizeof(BCars)];

new Fuel;

new VehicleName[][] = {
  "Landstalker",
  "Bravura",
  "Buffalo",
  "Linerunner",
  "Pereniel",
  "Sentinel",
  "Dumper",
  "Firetruck",
  "Trashmaster",
  "Stretch",
  "Manana",
  "Infernus",
  "Voodoo",
  "Pony",
  "Mule",
  "Cheetah",
  "Ambulance",
  "Leviathan",
  "Moonbeam",
  "Esperanto",
  "Taxi",
  "Washington",
  "Bobcat",
  "Mr Whoopee",
  "BF Injection",
  "Hunter",
  "Premier",
  "Enforcer",
  "Securicar",
  "Banshee",
  "Predator",
  "Bus",
  "Rhino",
  "Barracks",
  "Hotknife",
  "Trailer",
  "Previon",
  "Coach",
  "Cabbie",
  "Stallion",
  "Rumpo",
  "RC Bandit",
  "Romero",
  "Packer",
  "Monster Truck",
  "Admiral",
  "Squalo",
  "Seasparrow",
  "Pizzaboy",
  "Tram",
  "Trailer",
  "Turismo",
  "Speeder",
  "Reefer",
  "Tropic",
  "Flatbed",
  "Yankee",
  "Caddy",
  "Solair",
  "Berkley's RC Van",
  "Skimmer",
  "PCJ-600",
  "Faggio",
  "Freeway",
  "RC Baron",
  "RC Raider",
  "Glendale",
  "Oceanic",
  "Sanchez",
  "Sparrow",
  "Patriot",
  "Quad",
  "Coastguard",
  "Dinghy",
  "Hermes",
  "Sabre",
  "Rustler",
  "ZR-350",
  "Walton",
  "Regina",
  "Comet",
  "BMX",
  "Burrito",
  "Camper",
  "Marquis",
  "Baggage",
  "Dozer",
  "Maverick",
  "News Chopper",
  "Rancher",
  "FBI Rancher",
  "Virgo",
  "Greenwood",
  "Jetmax",
  "Hotring",
  "Sandking",
  "Blista Compact",
  "Police Maverick",
  "Boxville",
  "Benson",
  "Mesa",
  "RC Goblin",
  "Hotring Racer",
  "Hotring Racer",
  "Bloodring Banger",
  "Rancher",
  "Super GT",
  "Elegant",
  "Journey",
  "Bike",
  "Mountain Bike",
  "Beagle",
  "Cropdust",
  "Stunt",
  "Tanker",
  "RoadTrain",
  "Nebula",
  "Majestic",
  "Buccaneer",
  "Shamal",
  "Hydra",
  "FCR-900",
  "NRG-500",
  "HPV1000",
  "Cement Truck",
  "Tow Truck",
  "Fortune",
  "Cadrona",
  "FBI Truck",
  "Willard",
  "Forklift",
  "Tractor",
  "Combine",
  "Feltzer",
  "Remington",
  "Slamvan",
  "Blade",
  "Freight",
  "Streak",
  "Vortex",
  "Vincent",
  "Bullet",
  "Clover",
  "Sadler",
  "Firetruck",
  "Hustler",
  "Intruder",
  "Primo",
  "Cargobob",
  "Tampa",
  "Sunrise",
  "Merit",
  "Utility",
  "Nevada",
  "Yosemite",
  "Windsor",
  "Monster Truck",
  "Monster Truck",
  "Uranus",
  "Jester",
  "Sultan",
  "Stratum",
  "Elegy",
  "Raindance",
  "RC Tiger",
  "Flash",
  "Tahoma",
  "Savanna",
  "Bandito",
  "Freight",
  "Trailer",
  "Kart",
  "Mower",
  "Duneride",
  "Sweeper",
  "Broadway",
  "Tornado",
  "AT-400",
  "DFT-30",
  "Huntley",
  "Stafford",
  "BF-400",
  "Newsvan",
  "Tug",
  "Trailer",
  "Emperor",
  "Wayfarer",
  "Euros",
  "Hotdog",
  "Club",
  "Trailer",
  "Trailer",
  "Andromada",
  "Dodo",
  "RC Cam",
  "Launch",
  "Police Car (LSPD)",
  "Police Car (SFPD)",
  "Police Car (LVPD)",
  "Police Ranger",
  "Picador",
  "S.W.A.T. Van",
  "Alpha",
  "Phoenix",
  "Glendale",
  "Sadler",
  "Luggage Trailer",
  "Luggage Trailer",
  "Stair Trailer",
  "Boxville",
  "Farm Plow",
  "Utility Trailer"
};

enum vInfo
{
	vBID,
	vModel,
	vFuel,
	Float:vX,
	Float:vY,
	Float:vZ,
	Float:vAngel,
 	vCol,
 	vCol2,
	vOwner[128],
	vCost,
	vLocked,
	vPlate,
	vFile[256]
};

new VehicleInfo[sizeof(BCars)][vInfo];

forward SaveOwnedVehicles();
forward LoadOwnedVehicles();

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
  BCars = 0;
	LoadOwnedVehicles();
	SetTimerEx("SaveOwnedVehicles",60000,1);
	new id=0;
  VehicleInfo[id][vModel] = 487;
  VehicleInfo[id][vX] = 1538.2303;
  VehicleInfo[id][vY] = -1658.9150;
  VehicleInfo[id][vZ] = 6.0884;
  VehicleInfo[id][vAngel] = 359.6748;
  VehicleInfo[id][vCol] = 0
  VehicleInfo[id][vCol2] = 0;
  	VehicleInfo[id][vPlate] = id;
  	VehicleInfo[id][vFuel] = 90;
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\nLoaded!");
}

#endif

public OnGameModeInit()
{
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
  CreateInfoDraw(vehicleid);
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
  
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new DriverName[MAX_PLAYER_NAME], vehicleid;
	vehicleid = GetPlayerVehicleID(playerid);
	GetPlayerName(playerid,DriverName,sizeof(DriverName));
	for(new i; i<sizeof(BCars); i++)
	{
	  if(vehicleid == VehicleInfo[i][vBID])
	  {
			if(strcmp(DriverName,VehicleInfo[i][vOwner], true ) == 0)
			{
			
			} else {
	 			SendClientMessage(playerid,0xFFFFFFAA,"Dieses Autogehцrt NICHT dir.");
			}
		}
	}
	UpdateVehicleInfo(vehicleid);
	return 1;
}

public OnVehicleRespray(vehicleid, color1, color2)
{
	for(new i; i<sizeof(BCars); i++)
	{
	  if(vehicleid == VehicleInfo[i][vBID])
	  {
	    VehicleInfo[i][vCol] = color1;
	    VehicleInfo[i][vCol2] = color2;
	  }
	}
}

public LoadOwnedVehicles()
{
	for(new i; i<sizeof(BCars); i++)
	{
	  LoadFromFile(i);
	}
}

public SaveOwnedVehicles()
{
	for(new i; i<sizeof(BCars); i++)
	{
	  SaveToFile(i);
	}
}

SaveToFile(id)
{
	format(VehicleInfo[id][vFile],128,"vehicles/%d.car",id);
	if(dini_Exists(VehicleInfo[id][vFile]))
	{
	  dini_Remove(VehicleInfo[id][vFile]);
	}
	dini_Create(VehicleInfo[id][vFile]);
	dini_IntSet(VehicleInfo[id][vFile],"Model",VehicleInfo[id][vModel]);
	dini_IntSet(VehicleInfo[id][vFile],"Fuel",VehicleInfo[id][vFuel]);
	dini_IntSet(VehicleInfo[id][vFile],"Owner",VehicleInfo[id][vOwner]);
	dini_IntSet(VehicleInfo[id][vFile],"Cost",VehicleInfo[id][vCost]);
	dini_BoolSet(VehicleInfo[id][vFile],"Locked",VehicleInfo[id][vLocked]);
	dini_IntSet(VehicleInfo[id][vFile],"Plate",VehicleInfo[id][vPlate]);
	dini_FloatSet(VehicleInfo[id][vFile],"X",VehicleInfo[id][vX]);
	dini_FloatSet(VehicleInfo[id][vFile],"Y",VehicleInfo[id][vY]);
	dini_FloatSet(VehicleInfo[id][vFile],"Z",VehicleInfo[id][vZ]);
	dini_FloatSet(VehicleInfo[id][vFile],"Angel",VehicleInfo[id][vAngel]);
	dini_IntSet(VehicleInfo[id][vFile],"Color",VehicleInfo[id][vCol]);
	dini_IntSet(VehicleInfo[id][vFile],"Color2",VehicleInfo[id][vCol2]);
	return 1;
}

LoadFromFile(id)
{
	new File[256];
  format(File,sizeof(File),"vehicles/%d.car",id);
  VehicleInfo[id][vFile] = File;
  if(dini_Exists(VehicleInfo[id][vFile]))
  {
    if(dini_Isset(VehicleInfo[id][vFile],"X") && dini_Isset(VehicleInfo[id][vFile],"Y") && dini_Isset(VehicleInfo[id][vFile],"Z") && dini_Isset(VehicleInfo[id][vFile],"angel"))
    {
      VehicleInfo[id][vModel] = dini_Int(VehicleInfo[id][vFile],"Model");
      VehicleInfo[id][vFuel] = dini_Int(VehicleInfo[id][vFile],"Fuel");
      format(VehicleInfo[id][vOwner],128,dini_Get(VehicleInfo[id][vFile],"Owner"));
      VehicleInfo[id][vCost] = dini_Int(VehicleInfo[id][vFile],"Cost");
      VehicleInfo[id][vLocked] = dini_Bool(VehicleInfo[id][vFile],"Locked");
      VehicleInfo[id][vPlate] = dini_Int(VehicleInfo[id][vFile],"Plate");
      VehicleInfo[id][vCol] = dini_Int(VehicleInfo[id][vFile],"Color");
      VehicleInfo[id][vCol2] = dini_Int(VehicleInfo[id][vFile],"Color2");
      VehicleInfo[id][vX] = dini_Float(VehicleInfo[id][vFile],"X");
      VehicleInfo[id][vY] = dini_Float(VehicleInfo[id][vFile],"Y");
      VehicleInfo[id][vZ] = dini_Float(VehicleInfo[id][vFile],"Z");
      VehicleInfo[id][vAngel] = dini_Float(VehicleInfo[id][vFile],"Angel");
      CreateFileCar(id);
      return 1;
		}
  }
	return 1;
}

CreateFileCar(id)
{
	VehicleInfo[id][vBID] = CreateVehicle(
  VehicleInfo[id][vModel],
  VehicleInfo[id][vX],
  VehicleInfo[id][vY],
  VehicleInfo[id][vZ],
  VehicleInfo[id][vAngel],
  VehicleInfo[id][vCol],
  VehicleInfo[id][vCol2],
  999999999
	);
  SetVehicleNumberPlate(VehicleInfo[id][vBID], VehicleInfo[id][vPlate]);
  Fuel = VehicleInfo[id][vFuel];
  return 1;
}

CreateInfoDraw(vehicleid)
{
  VehName[vehicleid] = TextDrawCreate(453.000000,339.000000,"Name: name");
	VehOwner[vehicleid] = TextDrawCreate(453.000000,354.000000,"Halter: name");
	TextDrawAlignment(VehName[vehicleid],0);
	TextDrawAlignment(VehOwner[vehicleid],0);
	TextDrawBackgroundColor(VehName[vehicleid],0x000000ff);
	TextDrawBackgroundColor(VehOwner[vehicleid],0x000000ff);
	TextDrawFont(VehName[vehicleid],1);
	TextDrawLetterSize(VehName[vehicleid],0.599999,1.200000);
	TextDrawFont(VehOwner[vehicleid],1);
	TextDrawLetterSize(VehOwner[vehicleid],0.599999,1.200000);
	TextDrawColor(VehName[vehicleid],0xffffffff);
	TextDrawColor(VehOwner[vehicleid],0xffffffff);
	TextDrawSetOutline(VehName[vehicleid],1);
	TextDrawSetOutline(VehOwner[vehicleid],1);
	TextDrawSetProportional(VehName[vehicleid],1);
	TextDrawSetProportional(VehOwner[vehicleid],1);
	TextDrawSetShadow(VehName[vehicleid],1);
	TextDrawSetShadow(VehOwner[vehicleid],1);
}

UpdateVehicleInfo(vehicleid)
{
  new str[256];
  format(str,sizeof(str),"Name: %d",VehicleName[GetVehicleModel(vehicleid)-400]);
	TextDrawSetString(VehName[vehicleid],str);
	for(new i; i<sizeof(BCars); i++)
	{
	  if(VehicleInfo[i][vBID] == vehicleid)
	  {
 			format(str,sizeof(str),"Halter: %d",VehicleInfo[i][vOwner]);
			TextDrawSetString(VehName[vehicleid],str);
		}
	}
}

SetUserOwnCar(playerid,Bool)
{
	UserOwnageOfCar[playerid] = Bool;
	return 1;
}

DoesUserOwnCar(playerid)
{
	new Name[MAX_PLAYER_NAME],outp; outp = 0;
	GetPlayerName(playerid,Name,sizeof(Name));
	for(new i; i<sizeof(BCars); i++)
	{
		if(strcmp(Name,VehicleInfo[i][vOwner], true ) == 0)
		{
			outp = 1;
		}
	}
	return outp;
}

ShowVehicleStats(playerid,plate)
{
	new vehicle; vehicle = -255;
  for(new i; i<sizeof(BCars); i++)
  {
    if(VehicleInfo[i][vPlate] == plate)
    {
      vehicle = i;
    }
  }
  if(vehicle == -255)
  {
    SendClientMessage(playerid,0xFFFFFFAA,"Fahrzeug wurde nicht gefunden");
  } else {
    new msg[256]; new owner[256];
    format(owner,sizeof(owner),"OFFLINE");
    SendClientMessage(playerid,0xFFFFFFAA,"|______Vehicle Check_____|");
		for(new i; i<MAX_PLAYERS; i++)
		{
		  new pname[MAX_PLAYER_NAME]; GetPlayerName(i,pname,sizeof(pname));
		  if(strcmp(pname,VehicleInfo[vehicle][vOwner], true ) == 0)
			{
			  format(owner,sizeof(owner),"ONLINE (%d)",i);
			}
    format(msg,sizeof(msg),"Owner: %s, %s",VehicleInfo[vehicle][vOwner],owner);
    SendClientMessage(playerid,0xFFFFFFAA,msg);
  }

}
Whats the Problem
Reply
#2

well shuldn't yo ufirst create a file with vehice info and loading it create tge veguckes according to the information given in the file?
Reply
#3

why? i do Create.. and nothing happens.. its just to test and i created a file and.. the same?! Whats wrong.. i can't find the bug and the compiler too....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)