SA-MP Forums Archive
Licenseplate Saving - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Licenseplate Saving (/showthread.php?tid=583651)



Licenseplate Saving - Zens - 29.07.2015

How can I possibly combine the licenseplate system with MySQL?

Here is the CMD:
Код:
CMD:licenseplate(playerid,params[])
{
    if(PlayerData[playerid][pLevel] < 1)
	return SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be level 1 use this command");
	if(GetPlayerState(playerid) != 2)
	return SendClientMessage(playerid,-1,"Error: You have to be the driver of a vehicle to change its licence plate");
    new VehicleID = GetPlayerVehicleID(playerid), LModel = GetVehicleModel(VehicleID);
    switch(LModel)
    {
    	case 448,461,462,463,468,471,509,510,521,522,523,581,586, 449: return SendClientMessage(playerid,-1,"ERROR: You can not tune this vehicle");
    }
	new plate[32];
	if(sscanf(params,"s[32]",plate)) return SendClientMessage(playerid,-1,"Correct Usage : /licenseplate [PLATE] ");
	new Float:pos[3];
	GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
	SetVehicleNumberPlate(VehicleID, plate);
	SetVehicleToRespawn(VehicleID);
	SetVehiclePos(VehicleID, pos[0], pos[1], pos[2]);
 	SetTimerEx("TuneLCar",4000,0,"d",VehicleID);
 	PutPlayerInVehicle(playerid,VehicleID,0);
 	PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
	return 1;
}
Car enum:
Код:
enum carData {
	carID,
	carExists,
	carModel,
	carOwner,
	Float:carPos[4],
	carColor1,
	carColor2,
	carPaintjob,
	carLocked,
	carMods[14],
	carImpounded,
	carImpoundPrice,
	carFaction,
	carWeapons[5],
	carAmmo[5],
	carVehicle
};



Re: Licenseplate Saving - Abagail - 29.07.2015

I don't see any type of MySQL anything you here. Are you trying to simply place it into the enum and save it into MySQL or what?


Re: Licenseplate Saving - Zens - 29.07.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
I don't see any type of MySQL anything you here. Are you trying to simply place it into the enum and save it into MySQL or what?
Well, I've added the license plate to the enums/the whole MySQL savings. However, I'm abit lost on how to implement it into the cmd:licenseplate. It's carPlate fyi. Should I stock it somehow?

Код:
CMD:licenseplate(playerid, params[])
{
	if(GetPlayerState(playerid) != 2)
	return SendClientMessage(playerid,-1,"Error: You have to be the driver of a vehicle to change its licence plate");
    new vehicleid = GetPlayerVehicleID(playerid), LModel = GetVehicleModel(vehicleid);
    switch(LModel)
    {
    	case 448,461,462,463,468,471,509,510,521,522,523,581,586, 449: return SendClientMessage(playerid,-1,"ERROR: You can not tune this vehicle");
    }
	new plate[32];
	if(sscanf(params,"s[32]",plate)) return SendClientMessage(playerid,-1,"Correct Usage : /licenseplate [PLATE] ");
	new Float:pos[3];
	GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
	SetVehicleNumberPlate(vehicleid, plate);
	SetVehicleToRespawn(vehicleid);
	SetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
 	SetTimerEx("TuneLCar",4000,0,"d",vehicleid);
 	PutPlayerInVehicle(playerid,vehicleid,0);
 	PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
	return 1;
}



Re: Licenseplate Saving - Abagail - 30.07.2015

You mean you want to set the string simply? Well, ****** would've helped or the search function but something such as this should suffice:

pawn Код:
strmid(YourEnum[vehicleid][carPlate], plate, 0, strlen(plate));



Re: Licenseplate Saving - Zens - 30.07.2015

I'm still abit lost on this, been searching around for a while now.. Sorry
I want it to save the carPlate into the database upon the usage of /licenseplate.. Right now it just changes the plate, but doesnt really save together with the car system.


Re: Licenseplate Saving - Zens - 30.07.2015

Push... Anyone who knows?


Re: Licenseplate Saving - Abagail - 30.07.2015

Show the code you use for saving the vehicle.


Re: Licenseplate Saving - Zens - 30.07.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Show the code you use for saving the vehicle.
Код:
Car_Save(carid)
{
	static
	    query[900];

	if (CarData[carid][carVehicle] != INVALID_VEHICLE_ID)
	{
	    for (new i = 0; i < 14; i ++) {
			CarData[carid][carMods][i] = GetVehicleComponentInSlot(CarData[carid][carVehicle], i);
	    }
	}
	format(query, sizeof(query), "UPDATE `cars` SET `carModel` = '%d', `carOwner` = '%d', `carPosX` = '%.4f', `carPosY` = '%.4f', `carPosZ` = '%.4f', `carPosR` = '%.4f', `carPlate` = '%d', `carColor1` = '%d', `carColor2` = '%d', `carPaintjob` = '%d', `carLocked` = '%d'",
        CarData[carid][carModel],
        CarData[carid][carOwner],
        CarData[carid][carPos][0],
        CarData[carid][carPos][1],
        CarData[carid][carPos][2],
        CarData[carid][carPos][3],
        CarData[carid][carPlate],
        CarData[carid][carColor1],
        CarData[carid][carColor2],
        CarData[carid][carPaintjob],
        CarData[carid][carLocked]
	);
	format(query, sizeof(query), "%s, `carMod1` = '%d', `carMod2` = '%d', `carMod3` = '%d', `carMod4` = '%d', `carMod5` = '%d', `carMod6` = '%d', `carMod7` = '%d', `carMod8` = '%d', `carMod9` = '%d', `carMod10` = '%d', `carMod11` = '%d', `carMod12` = '%d', `carMod13` = '%d', `carMod14` = '%d'",
		query,
		CarData[carid][carMods][0],
		CarData[carid][carMods][1],
		CarData[carid][carMods][2],
		CarData[carid][carMods][3],
		CarData[carid][carMods][4],
		CarData[carid][carMods][5],
		CarData[carid][carMods][6],
		CarData[carid][carMods][7],
		CarData[carid][carMods][8],
		CarData[carid][carMods][9],
		CarData[carid][carMods][10],
		CarData[carid][carMods][11],
		CarData[carid][carMods][12],
		CarData[carid][carMods][13]
	);
	format(query, sizeof(query), "%s, `carImpounded` = '%d', `carImpoundPrice` = '%d', `carFaction` = '%d', `carWeapon1` = '%d', `carWeapon2` = '%d', `carWeapon3` = '%d', `carWeapon4` = '%d', `carWeapon5` = '%d', `carAmmo1` = '%d', `carAmmo2` = '%d', `carAmmo3` = '%d', `carAmmo4` = '%d', `carAmmo5` = '%d' WHERE `carID` = '%d'",
		query,
		CarData[carid][carImpounded],
		CarData[carid][carImpoundPrice],
		CarData[carid][carFaction],
		CarData[carid][carWeapons][0],
		CarData[carid][carWeapons][1],
		CarData[carid][carWeapons][2],
		CarData[carid][carWeapons][3],
		CarData[carid][carWeapons][4],
		CarData[carid][carAmmo][0],
		CarData[carid][carAmmo][1],
		CarData[carid][carAmmo][2],
		CarData[carid][carAmmo][3],
		CarData[carid][carAmmo][4],
		CarData[carid][carID]
	);
	return mysql_function_query(g_iHandle, query, false, "", "");
}



Re: Licenseplate Saving - Abagail - 30.07.2015

Is "carid" the object of the player's vehicle or the SA:MP vehicle ID?


Re: Licenseplate Saving - Zens - 30.07.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Is "carid" the object of the player's vehicle or the SA:MP vehicle ID?
It's the players vehicle.