Balkan SA:MP

PAWN skriptanje, gamemodovi, filterskripte, include fajlovi, mape, pluginovi => Razgovor u vezi PAWN - skriptanja => Temu započeo: Agent 47 poslato Februar 05, 2018, 15:31:10 POSLE PODNE

Naslov: Bug oko pijece vozila tj kupovine
Poruka od: Agent 47 poslato Februar 05, 2018, 15:31:10 POSLE PODNE
Detaljan opis problema:Svi znate balkan express srv x14 verzija i kada udjem u prodajno vozilo pise marka vozila bike a vozilo je neko sasvim drugu i kad kucaj /v buy kupim i onda /v park stvori se u to sto pise kad se ulazi u njega i kad odem sa srv i opet udjem vozilo mi propada kroz farmu sta je problem?
Dio skripte://
Neke slike/video za lakse dobivanje pomoci(neobavezno)://
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: ᴜɴᴋɴᴏᴡɴɴɴ poslato Februar 05, 2018, 18:26:56 POSLE PODNE
Daj neki kod za prodajno vozilo tj. kad uÄ'eÅ¡, problem je u tome Å¡to koristiÅ¡ modove stare 5 godina i viÅ¡e. Preporučujem ti da se prebaciÅ¡ na neki noviji mod.
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: Agent 47 poslato Februar 05, 2018, 18:38:42 POSLE PODNE
@ᴜɴᴋɴᴏᴡɴɴɴ na ovoj slici izbacuje igracu kada udje u prodajno vozilo  prntscr.com/iai7wa a ova slika kada igrac parkira http://prntscr.com/iai8jq a ti ako imas neki edit gtarpa koji nije ubagan tj ovaj bug posalji mi :)
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: ᴜɴᴋɴᴏᴡɴɴɴ poslato Februar 05, 2018, 18:49:48 POSLE PODNE
Citat: Moren0 poslato Februar 05, 2018, 18:38:42 POSLE PODNE
@ᴜɴᴋɴᴏᴡɴɴɴ na ovoj slici izbacuje igracu kada udje u prodajno vozilo  prntscr.com/iai7wa a ova slika kada igrac parkira http://prntscr.com/iai8jq a ti ako imas neki edit gtarpa koji nije ubagan tj ovaj bug posalji mi :)
http://balkan-samp.com/forum/index.php?topic=81201.0
DL Link ne valja, zamoli Jakisica da ti da mod ako ga jos ima.
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: Agent 47 poslato Februar 05, 2018, 18:51:09 POSLE PODNE
Jesam pitao sam ga a sta da radim sad sa ovim bugom
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: ᴜɴᴋɴᴏᴡɴɴɴ poslato Februar 05, 2018, 18:58:39 POSLE PODNE
Pošalji cDescription
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: Agent 47 poslato Februar 05, 2018, 19:01:47 POSLE PODNE
za cDescription nema public nego se nalazi u linijama sad cu te sve linije slikati http://prntscr.com/iaikxy  http://prntscr.com/iail1x http://prntscr.com/iail5i http://prntscr.com/iail9e http://prntscr.com/iailea
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: xsar.p poslato Februar 05, 2018, 19:12:16 POSLE PODNE
Bolje ti je da napravis novi carownership sistem, imas jedan mali milion tutorijala.
I bolje stavi kod u [ pawn ] [ /pawn ]. Jer nam je tako lakse videti kod, a ne da prepisujemo sa slike.
COS tutorial: http://forum.sa-mp.com/showthread.php?t=416104
COS tutorial mySQL: http://forum.sa-mp.com/showthread.php?t=186495
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: Agent 47 poslato Februar 05, 2018, 19:57:16 POSLE PODNE
@Raptorâ,,¢  http://prntscr.com/iajge2 nece da udje na link
Naslov: Odg: Bug oko pijece vozila tj kupovine
Poruka od: xsar.p poslato Februar 05, 2018, 20:08:53 POSLE PODNE
Citat: Moren0 poslato Februar 05, 2018, 19:57:16 POSLE PODNE
@Raptorâ,,¢  http://prntscr.com/iajge2 nece da udje na link
Kako meni radi?
Izvoli ceo tut: Introduction:
In this tutorial, I will be showing you how to create an advance vehicle system using YINI and YCMD.





Prerequisites:
Y_INI => HERE
Y_COMMANDS => HERE





Step 1: The System

In this step, we will be doing the system. A system is the group of logics behind the function which can be reused.
Code:
enum vInfo // The name of the enum. For naming convention use the system's first letter in lowercase.
{
   vID, // The vehicle id used on the SA-MP to represent the vehicle.
   vModel, // The vehicle model of the vehicle.
   Float:vLoc[4], // The array which contains position and the rotation of the vehicle in 4 cells. So, basically {X = 0, Y = 1, Z = 2, R = 3}
   vColor1, // The primary color of the vehicle.
   vColor2, // The secondary color of the vehicle.
   vRespawn, // The vehicle respawn time.
   vOwner[MAX_PLAYER_NAME], // The vehicle's owner name. Remember string is a group of literal characters and the cells you provide should be the maximum length for that string.
   bool:vLocked // Bool representing if the vehicle is locked or not. (0 = False, 1 = True)
}
new VehicleInfo[MAX_VEHICLES][vInfo]; // We are now making use of our ENUM by declaring an array which will hold all of the dynamic vehicle's information.
// The first cell is going to be the vehicle id based on our system(Not SA-MP). It's use to reference the dynamic vehicle for later usage.
// The second cell is the ENUM we made it. ENUMs are bunch of constant variables stacked up with each other.
// Imagine the array when the system will be ready. VehicleInfo[0][vID] or VehicleInfo[1][vID].

new bool:vCreated[MAX_VEHICLES]; // This will account the vehicles which has been created for later usage. The reason why we use this is to save/load
// the vehicle only if the vehicle is created. Otherwise not.

stock VehiclePath(vehicleID) // Creating a function which will get the vehicle path dynamically based on the vehicle id of the system.
{
   new strPath[64]; // Declaring the variable which will hold and return the vehicle path by vehicle id.
   format(strPath, sizeof(strPath), "/vehicle/%d.ini"); // We are formatting the string so that it holds the file path based on the vehicle id. '%d' means it will be a whole number.
   
   return strPath; // Return the file path so that it can be manipulate later on.

stock VehicleGetFreeSlot() // This function is used to get the free slot available to be used on the vehicle. It will be the vehicle id.
{
   for(new i = 0; i < MAX_VEHICLES; i++) // Loop through all of the vehicles on the sa-mp world and increments the variable 'i' by 1.
   {
      if(!vCreated) return i; // If that 'i' isn't being used on any of our system's vehicle then return this vehicle id and make use of it.
   }
   
   return -1; // Return -1 because 0 is a valid vehicle id for our system as we are left with -1.
}
stock VehicleCreate(vehicleModel, Float:vehicleLoc[4], vehicleColor1, vehicleColor2, vehicleRespawn, vehicleOwner[], bool:vehicleLocked)
// This is our most important function. This will create the vehicle with the valid information provided on the arguments.
{
   new vehicleid = VehicleGetFreeSlot(); // Get the free slot and store it on the vehicleid variable.
   //Now, we will basically put the information from the arguments to our newly created vehicle's array.
   VehicleInfo[vehicleid][vModel] = vehicleModel; // Assign our vehicle's model id to the model id provided.
   VehicleInfo[vehicleid][vLoc] = vehicleLoc; // Assign our vehicle's position/rotation to the position/rotation provided.
   VehicleInfo[vehicleid][vColor1] = vehicleColor1; // Assign our vehicle's primary color to the primary color provided.
   VehicleInfo[vehicleid][vColor2] = vehicleColor2; // Assign our vehicle's secondary color to the secondary color provided.
   VehicleInfo[vehicleid][vRespawn] = vehicleRespawn; // Assign our vehicle's respawn time to the respawn time provided.
   format(VehicleInfo[vehicleid][vOwner], MAX_PLAYER_NAME, vehicleOwner); // Assign our vehicle's owner name to the owner name provided.
   VehicleInfo[vehicleid][vLocked] = vehicleLocked; // Assign our vehicle's lock data to the lock data provided.
   VehicleInfo[vehicleid][vID] = CreateVehicle(vehicleModel, vehicleLoc[0], vehicleLoc[1], vehicleLoc[2], vehicleLoc[3], vehicleColor1, vehicleColor2,
   vehicleRespawn); // Now we are doing two things. We are creating our vehicle on the sa-mp world based on the data provided as well as assigning the
   // sa-mp vehicle id to our system's vehicle id so that we can alter it later.
   vCreated[vehicleid] = true; // Tell our vehicle management variable that this vehicle creation has been done and it's now on the system.
   VehicleLock(vehicleid, VehicleInfo[vehicleid][vLocked]); // Toggle our vehicle's door based on the parameter.
   
   return vehicleid; // Return the newly created vehicle's system id.
}
stock VehicleGet(vehicleID)
// Get the current sa-mp vehicle information for the provided vehicle id
{
   GetVehiclePos(VehicleInfo[vehicleID][vID], VehicleInfo[vehicleID][vLoc][0], VehicleInfo[vehicleID][vLoc][1], VehicleInfo[vehicleID][vLoc][2]);
   // Get the current position of that vehicle and assign it to our system's vehicle information.
   GetVehicleZAngle(VehicleInfo[vehicleID][vID], VehicleInfo[vehicleID][vLoc][3]);
   // Get the current rotation of that vehicle and assign it to our system's vehicle information.
}
stock VehicleLoad(vehicleID, file[])
// This function will load the vehicle provided by the id when the server starts.
{
   INI_ParseFile(file, "LoadVehicleData", .bExtra = true, .extra = vehicleID); // Parse the vehicle data from the INI file.
   VehicleCreate(VehicleInfo[vehicleID][vModel],
   VehicleInfo[vehicleID][vLoc], VehicleInfo[vehicleID][vColor1], VehicleInfo[vehicleID][vColor2], VehicleInfo[vehicleID][vRespawn],
   VehicleInfo[vehicleID][vOwner], VehicleInfo[vehicleID][vLocked]); // Creates the vehicle from the information we loaded and parsed. Pretty self-explanatory.
}
forward public LoadVehicleData(vehicleID, name[], value[]);
public LoadVehicleData(vehicleID, name[], value[]) // This a callback with the parameter of the vehicleID send from our VehicleLoad function. This function will pretty much parse the data from the file.
{
   new strLoc[8]; // Will hold the location key name dynamically.
   // The first argument is the key and the second argument is the data which will hold the value of that key.
   INI_Int("model", VehicleInfo[vehicleID][vModel]);
   for(new i = 0; i < 4; i++) format(strLoc, sizeof(strLoc), "Loc%d", i), INI_Float(strLoc, VehicleInfo[vehicleID][vLoc]);
   // Looping through our location data and retrive it. Loc0 = LocX, Loc1 = LocY, Loc2 = LocZ, Loc3 = LocA.
   INI_Int("color1", VehicleInfo[vehicleID][vColor1]); // You should've guessed it by now.
   INI_Int("color2", VehicleInfo[vehicleID][vColor2]);
   INI_Int("respawn", VehicleInfo[vehicleID][vRespawn]);
   INI_String("owner", VehicleInfo[vehicleID][vOwner], MAX_PLAYER_NAME);
   VehicleInfo[vehicleID][vLocked] = INI_Int("locked") == 1 ? true : false;
   //Converting the locked data from int(whole number) to bool(true/false) and assign it.

   return 1;
}
stock VehicleSave(vehicleID) // This function will save our vehicle on the INI file and will create it if it doesn't exist.
{
   new INI:dFile = INI_Open(VehiclePath(vehicleID)); // Open/Create the file for our vehicle.
   new strLoc[8]; // Will hold the location key name dynamically.
   // The first argument is the file to write the second is the key and the third argument is the value it will write.
   INI_WriteInt(dFile, "model", VehicleInfo[vehicleID][vModel]);
   for(new i = 0; i < 4; i++) format(strLoc, sizeof(strLoc), "Loc%d", i), INI_Float(dFile, strLoc, VehicleInfo[vehicleID][vLoc]);
   // Looping through our location data and write it. Loc0 = LocX, Loc1 = LocY, Loc2 = LocZ, Loc3 = LocA.
   INI_WriteInt(dFile, "color1", VehicleInfo[vehicleID][vColor1]); // You should've guessed it by now.
   INI_WriteInt(dFile, "color2", VehicleInfo[vehicleID][vColor2]);
   INI_WriteInt(dFile, "respawn", VehicleInfo[vehicleID][vRespawn]);
   INI_WriteString(dFile, "owner", VehicleInfo[vehicleID][vOwner]);
   INI_WriteInt(dFile, "locked", VehicleInfo[vehicleID][vLocked] ? 1 : 0);
   //Converting the locked data from bool(true/false) to int(whole number) and write it.
   INI_Close(dFile);
}
stock VehicleLoadAll() // This function will load all of the system vehicles created and saved.
{
   new index = 0; // We need this variable to keep track of the id or the index of the file. Start it with 0 as the id.

   while(fexist(VehiclePath(index))) // If any system vehicle has been created before with that 0 id
   {
      VehicleLoad(index, VehiclePath(index)); // Then load that vehicle.
      index++; // And move on to another system vehicle id.
   }
   
   printf("Vehicles Loaded: %d", index); // Print out how many vehicles has been loaded.
}
stock VehicleSaveAll()
{
   new index = 0; // We need this variable to keep track of the id or the index of the file. Start it with 0 as the id.

   for(new i = 0; i < MAX_VEHICLES; i++) // Loop through the maximum amount of vehicles allowed by sa-mp.
   {
      if(vCreated) // If that is our system's vehicle and if it has been created
      {
         VehicleGet(index); // Get that vehicle's current data.
         VehicleSave(index); // Save that vehicle's data on the file.
         index++; // Move on to next vehicle.
      }
   }
   
   printf("Vehicles Saved: %d", index); // Print out how many vehicles has been saved.
}





Step 2: Implementing it on the gamemode
In this step, we will be implementing the vehicle system on the gamemode.
Code:
public OnGameModeInit()
{
   VehicleLoadAll(); // Load all vehicles when the main script starts.

   return 1;
}

public OnGameModeExit()
{
   VehicleSaveAll(); // Save all vehicles when the main script stops/ends.
   
   return 1;
}





Step 3: Creating the commands.
In this step, we will be creating the commands to be able to use for our vehicle system.
Code:
stock VehicleValid(vehicleID) //Get's the system's vehicle id from sa-mp's vehicle id.
{
   for(new i = 0; i < MAX_VEHICLES; i++) // For every vehicles till the maximum amount
   {
      if((vCreated) && (VehicleInfo[vID] == vehicleID)) return i; // Is this vehicle created and it's the same sa-mp id as the argument provided? Return the system's id then.
   }
   
   return -1; // Return invalid system's vehicle id if it was not found.
}
stock VehicleEngine(vehicleID, bool:toggle) // Toggles the vehicle engine with the first parameter being the system's vehicle id not sa-mp's
{
   new vehicleid = VehicleInfo[vehicleID][vID]; // Get's the sa-mp's vehicle id.
   new engine, lights, alarm, doors, bonnet, boot, objective; // The variables to hold the current vehicle state.
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); // Get's the current variable state and reference it to the variables.
    SetVehicleParamsEx(vehicleid, toggle, lights, alarm, doors, bonnet, boot, objective); // Set's the current vehicle state to be the same as before with just the engine being controlled by the bool:toggle parameter.
}
stock VehicleLock(vehicleID, bool:toggle) // Toggles the vehicle doors with the first parameter being the system's vehicle id not sa-mp's
{
   new vehicleid = VehicleInfo[vehicleID][vID]; // Get's the sa-mp's vehicle id.
   new engine, lights, alarm, doors, bonnet, boot, objective; // The variables to hold the current vehicle state.
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); // Get's the current variable state and reference it to the variables.
    SetVehicleParamsEx(vehicleid, engine, lights, alarm, toggle, bonnet, boot, objective); // Set's the current vehicle state to be the same as before with just the door being controlled by the bool:toggle parameter.
}

new bool:engine; // This will check if we should turn on/turn off the engine. (TRUE/FALSE)
YCMD:engine(playerid, params[], help) // The base YCMD command structure with the command name being /engine which will toggle the engine.
{
   if(help) return SendClientMessage(playerid, -1, "Allows to toggle the vehicle engine."); // Shows him the help messages. Check out Y_CMD for more info.

   new vehicleid = VehicleID(GetPlayerVehicleID(playerid)); // Get's our system vehicle id from our sa-mp's vehicle id.
   
   if((IsPlayerInAnyVehicle(playerid)) && (vehicleid != -1)) // If they are on a vehicle and if that vehicle is the system's vehicle.
   {