Hallo,
wie im Titel schon beschrieben, habe ich ein Problem mit meinem Autohaussystem. Ziemlich genau mit der Bestellung von Fahrzeugen.
Ich habe mir das vSpawner-Filterscript in den Gamemode kopiert, und ein paar Änderungen vorgenommen (MAX_ITEMS, etc.).
Hier der Code:
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
new curpage = GetPVarInt(playerid, "vspawner_page");
if(playertextid == gNextButtonTextDrawId[playerid] && GetPVarInt(playerid, "vspawner_active") != 0) {
if(curpage < (GetNumberOfPages() - 1)) {
SetPVarInt(playerid, "vspawner_page", curpage + 1);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
} else {
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
}
return 1;
}
else if(playertextid == gPrevButtonTextDrawId[playerid] && GetPVarInt(playerid, "vspawner_active") != 0) {
if(curpage > 0) {
SetPVarInt(playerid, "vspawner_page", curpage - 1);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
} else {
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
}
return 1;
}
if(GetPVarInt(playerid, "vspawner_active") != 0) {
new x;
while(x != SELECTION_ITEMS) {
if(playertextid == gSelectionItems[playerid][x]) {
ShowVehicleInfoData(playerid,x);
PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
DestroySelectionMenu(playerid);
CancelSelectTextDraw(playerid);
SetPVarInt(playerid, "vspawner_active", 0);
print("ShowInfoData1");
return 1;
}
x++;
}
}
}
return 1;
}
#define TOTAL_ITEMS 99
#define SELECTION_ITEMS 21
#define ITEMS_PER_LINE 7
#define HEADER_TEXT "Fahrzeugauswahl"
#define NEXT_TEXT "Weiter"
#define PREV_TEXT "Zurueck"
#define DIALOG_BASE_X 75.0
#define DIALOG_BASE_Y 130.0
#define DIALOG_WIDTH 550.0
#define DIALOG_HEIGHT 180.0
#define SPRITE_DIM_X 60.0
#define SPRITE_DIM_Y 70.0
new gTotalItems = TOTAL_ITEMS,gItemAt[MAX_PLAYERS];
new gItemList[TOTAL_ITEMS] = {
400,401,402,404,405,409,410,411,412,415,418,419,421,422,424,426,429,434,436,439,445,451,458,461,
462,463,466,467,468,471,474,475,477,478,479,480,481,482,483,489,491,492,495,496,500,505,506,507,508,
509,510,516,517,518,521,522,526,527,529,533,534,535,536,540,541,542,543,545,546,547,549,550,551,554,
555,558,559,560,561,562,565,566,567,568,573,575,576,579,580,581,585,586,587,589,600,602,603,604,605
};
new DealerVehPrice[99] = {
20000,
15000,
90000,
10000,
12500,
100000,
7500,
1500000,
15000,
750000,
7500,
12500,
20000,
8500,
35000,
15000,
400000,
90000,
10000,
17500,
13000,
800000,
6000,
5000,
1000,
3500,
5000,
5000,
11000,
4000,
10000,
10000,
80000,
5000,
10000,
125000,
100,
14000,
14000,
10500,
8300,
8300,
250000,
11500,
9900,
13400,
790000,
17500,
20000,
150,
200,
7500,
7500,
7500,
6000,
999999,
11100,
10900,
10500,
15000,
25000,
26500,
16000,
10000,
1500000,
7300,
6300,
13300,
9900,
9910,
8500,
9000,
10000,
10000,
20000,
25000,
80000,
90000,
14600,
35000,
25000,
11500,
15000,
35000,
170000,
10000,
10000,
35000,
12500,
5000,
10000,
5000,
13500,
15000,
6890,
30000,
50000,
4000,
4000,
};
public OnPlayerClickTextDraw(playerid,Text:clickedid)
{
if(clickedid == Text:INVALID_TEXT_DRAW && GetPVarInt(playerid, "vspawner_active") != 0) {
DestroySelectionMenu(playerid);
SetPVarInt(playerid, "vspawner_active", 0);
SetPVarInt(playerid, "vspawner_page", 0);
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
return 1;
}
return 1;
}
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
new curpage = GetPVarInt(playerid, "vspawner_page");
if(playertextid == gNextButtonTextDrawId[playerid] && GetPVarInt(playerid, "vspawner_active") != 0) {
if(curpage < (GetNumberOfPages() - 1)) {
SetPVarInt(playerid, "vspawner_page", curpage + 1);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
} else {
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
}
return 1;
}
else if(playertextid == gPrevButtonTextDrawId[playerid] && GetPVarInt(playerid, "vspawner_active") != 0) {
if(curpage > 0) {
SetPVarInt(playerid, "vspawner_page", curpage - 1);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
} else {
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
}
return 1;
}
if(GetPVarInt(playerid, "vspawner_active") != 0) {
new x;
while(x != SELECTION_ITEMS) {
if(playertextid == gSelectionItems[playerid][x]) {
ShowVehicleInfoData(playerid,x);
PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
DestroySelectionMenu(playerid);
CancelSelectTextDraw(playerid);
SetPVarInt(playerid, "vspawner_active", 0);
print("ShowInfoData1");
return 1;
}
x++;
}
}
return 1;
}
PlayerText:CreateModelPreviewTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:width, Float:height)
{
new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, "");
PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, 0x000000EE);
PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height);
PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, -16.0, 0.0, -55.0);
PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
PlayerTextDrawShow(playerid,txtPlayerSprite);
return txtPlayerSprite;
}
PlayerText:CreatePlayerBackgroundTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height)
{
new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos,
" ~n~");
PlayerTextDrawUseBox(playerid, txtBackground, 1);
PlayerTextDrawBoxColor(playerid, txtBackground, 0x00000099);
PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
PlayerTextDrawFont(playerid, txtBackground, 0);
PlayerTextDrawSetShadow(playerid, txtBackground, 0);
PlayerTextDrawSetOutline(playerid, txtBackground, 0);
PlayerTextDrawColor(playerid, txtBackground,0x000000FF);
PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
PlayerTextDrawBackgroundColor(playerid, txtBackground, 0x00000099);
PlayerTextDrawShow(playerid, txtBackground);
return txtBackground;
}
PlayerText:CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
{
new PlayerText:txtInit;
txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
PlayerTextDrawUseBox(playerid, txtInit, 0);
PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
PlayerTextDrawFont(playerid, txtInit, 0);
PlayerTextDrawSetShadow(playerid, txtInit, 0);
PlayerTextDrawSetOutline(playerid, txtInit, 1);
PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
PlayerTextDrawShow(playerid, txtInit);
return txtInit;
}
PlayerText:CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
{
new PlayerText:txtInit;
txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
PlayerTextDrawUseBox(playerid, txtInit, 1);
PlayerTextDrawBoxColor(playerid, txtInit, 0x000000FF);
PlayerTextDrawBackgroundColor(playerid, txtInit, 0x000000FF);
PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
PlayerTextDrawFont(playerid, txtInit, 1);
PlayerTextDrawSetShadow(playerid, txtInit, 0);
PlayerTextDrawSetOutline(playerid, txtInit, 0);
PlayerTextDrawColor(playerid, txtInit, 0x4A5A6BFF);
PlayerTextDrawSetSelectable(playerid, txtInit, 1);
PlayerTextDrawAlignment(playerid, txtInit, 2);
PlayerTextDrawTextSize(playerid, txtInit, Height, Width);
PlayerTextDrawShow(playerid, txtInit);
return txtInit;
}
PlayerText:CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
{
new PlayerText:txtInit;
txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
PlayerTextDrawUseBox(playerid, txtInit, 0);
PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
PlayerTextDrawFont(playerid, txtInit, 1);
PlayerTextDrawSetShadow(playerid, txtInit, 0);
PlayerTextDrawSetOutline(playerid, txtInit, 1);
PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
PlayerTextDrawShow(playerid, txtInit);
return txtInit;
}
public OnPlayerConnect(playerid)
{
gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
for(new x; x < SELECTION_ITEMS; x++) {
gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
}
gItemAt[playerid] = 0;
return 1;
}
stock DestroySelectionMenu(playerid)
{
DestroyPlayerModelPreviews(playerid);
PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);
gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
}
stock CreateSelectionMenu(playerid)
{
gBackgroundTextDrawId[playerid] = CreatePlayerBackgroundTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y + 20.0, DIALOG_WIDTH, DIALOG_HEIGHT);
gHeaderTextDrawId[playerid] = CreatePlayerHeaderTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y, HEADER_TEXT);
gCurrentPageTextDrawId[playerid] = CreateCurrentPageTextDraw(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y + 15.0);
gNextButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, NEXT_TEXT);
gPrevButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 90.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, PREV_TEXT);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
}
stock UpdatePageTextDraw(playerid)
{
new PageText[64+1];
format(PageText, 64, "%d/%d", GetPVarInt(playerid,"vspawner_page") + 1, GetNumberOfPages());
PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
}
stock ShowPlayerModelPreviews(playerid)
{
new x,linetracker;
new Float:BaseX = DIALOG_BASE_X;
new Float:BaseY = DIALOG_BASE_Y - (SPRITE_DIM_Y * 0.33);
new itemat = GetPVarInt(playerid, "vspawner_page") * SELECTION_ITEMS;
DestroyPlayerModelPreviews(playerid);
while(x != SELECTION_ITEMS && itemat < gTotalItems) {
if(linetracker == 0) {
BaseX = DIALOG_BASE_X + 25.0;
BaseY += SPRITE_DIM_Y + 1.0;
}
gSelectionItems[playerid][x] = CreateModelPreviewTextDraw(playerid, gItemList[itemat], BaseX, BaseY, SPRITE_DIM_X, SPRITE_DIM_Y);
gSelectionItemsTag[playerid][x] = gItemList[itemat];
BaseX += SPRITE_DIM_X + 1.0;
linetracker++;
if(linetracker == ITEMS_PER_LINE) linetracker = 0;
itemat++;
x++;
}
}
stock DestroyPlayerModelPreviews(playerid)
{
new x;
while(x != SELECTION_ITEMS) {
if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
}
x++;
}
}
stock GetNumberOfPages()
{
if((gTotalItems >= SELECTION_ITEMS) && (gTotalItems % SELECTION_ITEMS) == 0)
{
return (gTotalItems / SELECTION_ITEMS);
}
else return (gTotalItems / SELECTION_ITEMS) + 1;
}
//Wenn man ein Fahrzeug bestellen möchte(Auszug aus OnDialogResponse)
case 1: {
new str[256],i=pInfo[playerid][pAH];
format(str,sizeof str,"SELECT * FROM `Dealercars` WHERE `Seller` = '%d'",i);
mysql_query(str);
format(str,sizeof str,"");
mysql_store_result();
if(mysql_num_rows() > MAX_SELLERCARSPERSELLER) {
SendClientMessage(playerid,COLOR_LIGHTRED,"Du hast bereits die maximale Anzahl an Verkaufsfahrzeugen erreicht!");
} else {
if(Dealercarsordered < MAX_DEALERORDERS) {
DestroySelectionMenu(playerid);
SetPVarInt(playerid, "vspawner_active", 1);
CreateSelectionMenu(playerid);
SelectTextDraw(playerid, 0xACCBF1FF);
} else {
SendClientMessage(playerid,COLOR_LIGHTRED,"Der Importhändler hat gerade zu viel zu tun. Versuche es Später erneut!");
}
}
mysql_free_result();
}
stock ShowVehicleInfoData(playerid, selecteditem)
{
print("ShowInfoData2");
printf("%d | %d",playerid,selecteditem);
new str[512],rnd=random(2500);
format(str,sizeof str,"{FFFFFF}Du hast folgendes Fahrzeug ausgewählt.\n\nName: {00FF00}%s\n{FFFFFF}Importkosten: {FF0000}%s{FFFFFF}€\n{FFFFFF}Kostenaufschlag (für die Lieferanten): {FF0000}%s{FFFFFF}€\n\nGesamtkosten: {FF0000}%s{FFFFFF}€",PlayerVehicle[selecteditem],inspoints(DealerVehPrice[selecteditem]),inspoints(2000),inspoints(DealerVehPrice[selecteditem]+rnd));
SetPVarInt(playerid,"ImportVeh",selecteditem);
SetPVarInt(playerid,"Lieferkosten",rnd);
ShowPlayerDialog(playerid,DLG_AH_IMPORTCAR,DIALOG_STYLE_MSGBOX,"Fahrzeug importieren",str,"Import","Abbrechen");
return 1;
}
//Nochmal ein Auszug aus OnDialogRespnose
case DLG_AH_IMPORTCAR:
{
if(response) {
new veh=GetPVarInt(playerid,"ImportVeh"),lk=GetPVarInt(playerid,"Lieferkosten");
if(Dealercarsordered < MAX_DEALERORDERS) {
new i=pInfo[playerid][pAH];
if(CDid[i] == -1) {
if(AHInfo[i][zBank] >= DealerVehPrice[veh-400]+lk) {
AHInfo[i][zBank] -= DealerVehPrice[veh-400]+lk;
SaveCarDealer(i);
Dealercarsordered += 1;
SendClientMessage(playerid,COLOR_WHITE,"Du hast das Fahrzeug bestellt. Warte nun bis es von einem Trucker geliefert wird.");
SetTimerEx("ImportVehicle",720000,0,"dd",i,lk);
return 1;
} else {
SendClientMessage(playerid,COLOR_LIGHTRED,"Du hast nicht genug Geld auf der Autohauskasse, um dieses Fahrzeug zu bestellen!");
}
} else {
SendClientMessage(playerid,COLOR_LIGHTRED,"Du hast bereits ein Fahrzeug bestellt!");
}
} else {
SendClientMessage(playerid,COLOR_LIGHTRED,"Der Importhändler hat gerade zu viel zu tun. Versuche es Später erneut!");
}
} else { SetPVarInt(playerid,"ImportVeh",-1); SetPVarInt(playerid,"Lieferkosten",0); }
}
Ab hier ist dann der Wurm drin. Sind alle Bedingungen erfüllt, und man klickt auf "Import", bekommt man keine Meldung. Es wird kein Timer gestartet, nichts.
Zudem ist es so, dass wenn man sich z.B. auf der 2. Seite des "Menüs" befindet, dort auf ein Vehikel klickt, die VehikelID nicht aus dem Array (gItemList) entnommen, sondern 400+"CLICKEDID" gerechnet wird.
Auf das Fahrzeug im Menü (Textdraw) klicken ist kein Problem, da klappt alles.
Zu guter letzt hier noch der Public, der nicht aufgerufen wird:
public ImportVehicle(Seller, TruckReward)
{
new rnd=random(8),str[128];
CDid[Seller]=AddStaticVehicleEx(591,CDTrailerSpawn[rnd][0],CDTrailerSpawn[rnd][1],CDTrailerSpawn[rnd][2],CDTrailerSpawn[rnd][3],random(128),random(128),-1);
CDInfoLabel[CDid[Seller]]=Create3DTextLabel(str,COLOR_RED,CDTrailerSpawn[rnd][0],CDTrailerSpawn[rnd][1],CDTrailerSpawn[rnd][2],15,0,0);
format(str,sizeof str,"Lieferung für '%s'\nLieferbelohnung: %s€",AHInfo[Seller][zName],inspoints(TruckReward));
Attach3DTextLabelToVehicle(CDInfoLabel[CDid[Seller]],CDid[Seller],0.0,0.0,0.2);
return 1;
}
Was funktioniert da nicht? (Infos stehen im Expander)
lg
Deagle