12.04.2012, 21:30
Well, i am trying to create a lock/unlock system for the dealer ship, once you bought a car it automatically assigns you the owner of the car and you can lock/unlock it but im having so much trouble
Thank You
Please Help Me Please
pawn Код:
enum vInfo
{
vType,//Saving vehicles ID
VehicleName[100],//Saving Vehicle's Name - me ownz a turismo LOLz
Owner[MAX_PLAYER_NAME],//Saving the owner
Float:ParkPos[3],//THis is Pos X,Pos Y,and Pos Z,equvalent of 0,1, and 2[Pos[0]-X,etc.)
ModelID,//This is something YOU don't need,I have a different system :P
Float:vAngle,//The angle so when the car respawns it won't spawn with some crazy angle(float(E=MC^2)):D
Float:vHealth,//Saving vehicles health also,so if the car respawns won't be a new brand car,but will spawn with it's health
vColor1,//Color 1
vColor2//Color 2
}
pawn Код:
new VehicleInfo[MAX_VEHICLES][vInfo];
pawn Код:
if(dialogid == DIALOG_BUYVEHICLE)
{
if(response)
{
if(listitem == 0)
{
ShowPlayerDialog(playerid, DIALOG_CASUALVEHICLEMENU, DIALOG_STYLE_LIST, "Casual Car Menu", "TEST CAR - SENITAL", "Buy", "Cancel");
}
}
return 1;
}
if(dialogid == DIALOG_CASUALVEHICLEMENU)
{
if(response)
{
if(listitem == 0)
{
new pName[45];
new vehicleid = GetPlayerVehicleID(playerid);
CreateVehicle(405, 540.0750,-1281.7159,17.2422,309.3207, 0, 1, 0);
// lines added below
VehicleInfo[vehicleid][Owner]==1;//Don't forget to add to my enumeration vOwned
format(VehicleInfo[vehicleid][Owner],24,"%s",pName);//Sets the owner
}
}
return 1;
}
pawn Код:
CMD:lock(playerid,params[])
{
new vehicleid=GetPlayerVehicleID(playerid);
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"This command must be used only on a vehicle!");
else
{
if(VehicleInfo[vehicleid][Owner]==0) return SendClientMessage(playerid,COLOR_RED,"This is a civilian car!");
else
{
new pName[24];
GetPlayerName(playerid,pName,24);
if(!strcmp(pName,VehicleInfo[vehicleid][Owner]))//If the player owns the car
{
SetVehicleParamsEx(vehicleid,0,0,0,1,0,0,0);
SendClientMessage(playerid,COLOR_GREEN,"Car locked!");
}
else SendClientMessage(playerid,COLOR_RED,"This is not your car!");
}
}
return 1;
}
Thank You
Please Help Me Please