16.05.2015, 21:43
Hello guys,today i want to improve my gamemode by improving the vehicle dealership.
Let me explain,i have an dynamic dealership in my gamemode,but its the type of dealership which works with /acreatecar[the admin create the cars,the cars spawn and if someone enter on them they can /v buy them].
This is the problem,i want to change this into a special one: if a players goes to the dealership and type a command like /buycar infernus or /buycar turismo or maybe an advanced one with a dialog popping up.So what i want from you to know,i want some tips on how to make this happen,i want to modify this dealer,not to remove/replace it,i want to make it so players can buy cars themselves and after they purchase the car,the car would be on their name[they would be the owner] ,i hope you understood.
I have an idea doing this,i trying to make 1 command from 2 commands[ /acreatecar + /v buy] ,but i dont really know how,i want to merge those 2 commands into 1 command],any other tips or ideas are welcome.
This is the /acreatecar command :
And the /v buy command:
I dont want you to give me a script,i just want tips on how to do it,or maybe something to improve my knowledge of this type of dealership.
If you don`t understand what i`m trying to do,please reply.Thanks in advance [sorry for any english grammar mistake,i am not a native speaker]
Let me explain,i have an dynamic dealership in my gamemode,but its the type of dealership which works with /acreatecar[the admin create the cars,the cars spawn and if someone enter on them they can /v buy them].
This is the problem,i want to change this into a special one: if a players goes to the dealership and type a command like /buycar infernus or /buycar turismo or maybe an advanced one with a dialog popping up.So what i want from you to know,i want some tips on how to make this happen,i want to modify this dealer,not to remove/replace it,i want to make it so players can buy cars themselves and after they purchase the car,the car would be on their name[they would be the owner] ,i hope you understood.
I have an idea doing this,i trying to make 1 command from 2 commands[ /acreatecar + /v buy] ,but i dont really know how,i want to merge those 2 commands into 1 command],any other tips or ideas are welcome.
This is the /acreatecar command :
PHP код:
//===============================[/acreatecar]==================================
if(strcmp(cmd, "/acreatecar", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1339 || IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]");
return 1;
}
new car;
car = strval(tmp);
if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, "{0950F7}* Vehicle Number can't be below 400 or above 611 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]"); return 1; }
new color1;
color1 = strval(tmp);
if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, "{0950F7}* Color Number can't be below 0 or above 126 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]"); return 1; }
new color2;
color2 = strval(tmp);
if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, "{0950F7}* Color Number can't be below 0 or above 126 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]"); return 1; }
new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
new value = strval(tmp);
CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
CarInfo[thiscar][cValue] = value; CarInfo[thiscar][paintjob] = -1; LoadComponents(thiscar); PutPlayerInVehicle(playerid,thiscar,0);
strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
// format(TextCar, sizeof(TextCar), "{EE1111}ForSale: {80D52B}• $%d •", CarInfo[thiscar][cValue]);
// TextUpCar[thiscar] = Create3DTextLabel(TextCar, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
// Attach3DTextLabelToVehicle(TextUpCar[thiscar], thiscar, 0.0, 0.0, 0.1);
format(string, sizeof(string), " Personal Car was created.ID: {FFFFFF}[%d]", thiscar);
SendClientMessage(playerid, COLOR_GREEN, string);
//ShowPlayerDialog(playerid,DIALOGIDSETOWNER,DIALOG_STYLE_INPUT,"{E0941B}Vehicle owner","Scrie ID/Nume player\nca sa il faci proprietar:","Enter","Close");
OnCarUpdate();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, " You are not authorized to use that command ");
return 1;
}
}
PHP код:
else if(strcmp(x_nr,"buy",true) == 0)
{
if(IsAnOwnableCar(idcar))
{
if(PlayerInfo[playerid][pPcarkey] == -1) { }
else if(PlayerInfo[playerid][pPcarkey2] == -1) { }
else if(PlayerInfo[playerid][pPcarkey3] == -1) { }
else { SendClientMessage(playerid, COLOR_GREY, "* Detii 3 masini!"); return 1; }
if(CarInfo[idcar][cOwned]==1)
{
SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car.");
return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo[idcar][cValue])
{
if(PlayerInfo[playerid][pPcarkey] == -1) { PlayerInfo[playerid][pPcarkey] = idcar; }
else if(PlayerInfo[playerid][pPcarkey2] == -1) { PlayerInfo[playerid][pPcarkey2] = idcar; }
else if(PlayerInfo[playerid][pPcarkey3] == -1) { PlayerInfo[playerid][pPcarkey3] = idcar; }
else { return 1; }
CarInfo[idcar][cOwned] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo[idcar][cValue]);
Delete3DTextLabel(TextUpCar[idcar]);
//format(TextCar, sizeof(TextCar), "{EE1111}Owner: {0099FF}• %s •", CarInfo[idcar][cOwner]);
//TextUpCar[idcar] = Create3DTextLabel(TextCar, 0x33AAFFFF, 0.0, 0.0, 0.0, 25, 0, 1);
//Attach3DTextLabelToVehicle(TextUpCar[idcar], idcar, 0.0, 0.0, 0.1);
OnCarUpdate(); SavePlayerData(playerid);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid, "~w~Felicitari~n~Nu uita sa o parchezi cu /v park !", 5000, 3);
TogglePlayerControllable(playerid, 1);
return 1;
}
If you don`t understand what i`m trying to do,please reply.Thanks in advance [sorry for any english grammar mistake,i am not a native speaker]