08.09.2018, 22:11
Hello, I am trying to make a Gun dealer system and a 24/7 system, I made both of them in a seperate filterscript and they seem to be conflicting. If I use either of them seperately they both work as intended, as soon as both are enabled one of them begins to malfunction.
I think this is because of a problem with dialogid, I don't quite understand how dialogid works and this was my best attempt at this. I will leave relevant code below.
24/7 Script
Gun Dealer code
I think this is because of a problem with dialogid, I don't quite understand how dialogid works and this was my best attempt at this. I will leave relevant code below.
24/7 Script
Код:
#define FILTERSCRIPT #include <a_samp> #if defined FILTERSCRIPT #define COLOR_RED 0xAA3333AA #define COLOR_LIME 0x10F441AA new StorePickup; new PlayerCig; new PlayerSprunk; new PlayerBeer; public OnFilterScriptInit() { print("\n--------------------------------------"); print("24/7 FilterScript by Brian3898"); print("--------------------------------------\n"); StorePickup = CreatePickup(1274,1,-28.0080,-89.6934,1003.5469,-1); return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (!strcmp("/sprunk", cmdtext, true, 7)) { if(PlayerSprunk == 0) { SendClientMessage(playerid, COLOR_RED, "SERVER: You don't have any Sprunk!"); } else { SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_SPRUNK); PlayerSprunk = 0; } return 1; } if (!strcmp("/beer", cmdtext, true, 5)) { if(PlayerBeer == 0) { SendClientMessage(playerid, COLOR_RED, "SERVER: You don't have any beer!"); } else { SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER); PlayerBeer = 0; } return 1; } if(!strcmp("/cig", cmdtext, true, 4)) { if(PlayerCig == 0) { SendClientMessage(playerid, COLOR_RED, "SERVER: You don't have any cigarettes!"); } else { SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY); PlayerCig = PlayerCig - 1; } return 1; } return 0; } public OnPlayerPickUpPickup(playerid, pickupid) { if(pickupid == StorePickup) { ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"24/7","Redwood Cigarettes($20)\nSprunk($20)\nBeer($20)\nSpray Can($50)\nBaseball Bat($100)","Buy", "Cancel"); } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case 1: { if(response) { switch(listitem) { case 0: { if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, "SERVER: You cannot afford this item!"); GivePlayerMoney(playerid, -20); SendClientMessage(playerid, COLOR_LIME, "SERVER: You have bought a pack of Redwoods."); PlayerCig = 5; return 1; } case 1: { if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, "SERVER: You cannot afford this item!"); GivePlayerMoney(playerid, -20); SendClientMessage(playerid, COLOR_LIME, "SERVER: You have bought a can of Sprunk."); PlayerSprunk = 1; return 1; } case 2: { if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, "SERVER: You cannot afford this item!"); GivePlayerMoney(playerid, -20); SendClientMessage(playerid, COLOR_LIME, "SERVER: You have bought a botle of beer."); PlayerBeer = 1; return 1; } case 3: { if(GetPlayerMoney(playerid) < 50) return SendClientMessage(playerid, COLOR_RED, "SERVER: You cannot afford this item!"); GivePlayerMoney(playerid, -20); SendClientMessage(playerid, COLOR_LIME, "SERVER: You have bought a spray can."); GivePlayerWeapon(playerid, 41, 1000); return 1; } case 4: { if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, COLOR_RED, "SERVER: You cannot afford this item!"); GivePlayerMoney(playerid, -20); SendClientMessage(playerid, COLOR_LIME, "SERVER: You have bought a Baseball Bat."); GivePlayerWeapon(playerid, 5, 1); return 1; } } } } } return 1; }
Код:
#define FILTERSCRIPT #include <a_samp> #if defined FILTERSCRIPT #define COLOR_RED 0xAA3333AA new GunDealerOGF; new GunDealerLSB; new GunDealerLSV; public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Blank Filterscript by your name here"); print("--------------------------------------\n"); GunDealerOGF = CreatePickup(346,1,2439.7334,-1900.7236,13.5534,-1); GunDealerLSB = CreatePickup(346,1,1893.8046,-1069.5847,23.9375,-1); GunDealerLSV = CreatePickup(346,1,2769.6465,-1367.8754,39.7060,-1); return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { if(pickupid == GunDealerOGF) { ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Guns","Colt 45 ($500)\nTEC-9 ($1000)\nMicro-UZI ($1000)\nShotgun ($2000)\nDesert Eagle ($2500)","Choose","Cancel"); } if(pickupid == GunDealerLSB) { ShowPlayerDialog(playerid,3,DIALOG_STYLE_LIST,"Guns","Colt 45 ($500)\nTEC-9 ($1000)\nMicro-UZI ($1000)\nShotgun ($2000)\nDesert Eagle ($2500)","Choose","Cancel"); } if(pickupid == GunDealerLSV) { ShowPlayerDialog(playerid,4,DIALOG_STYLE_LIST,"Guns","Colt 45 ($500)\nTEC-9 ($1000)\nMicro-UZI ($1000)\nShotgun ($2000)\nDesert Eagle ($2500)","Choose","Cancel"); } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) // We use switch since it is quicker than using multiple 'if' statements { case 2: // OGF Dealer { if(response) // If the player didn't cancel the dialog { switch(listitem) // Switch through the list items, quicker and is easier for adding more guns to the dialog { case 0: // List item 0 { if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,22,300); // Give the player the weapon GivePlayerMoney(playerid,-500); // Give the player $-500 return 1; } case 1: // List item 1 { if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,32,300); // Give the player the weapon GivePlayerMoney(playerid,-1000); // Give the player $-900 return 1; } case 2: // List item 2 { if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,28,300); // Give the player the weapon GivePlayerMoney(playerid,-1000); // Give the player $-900 return 1; } case 3: // List item 3 { if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,25,25); // Give the player the weapon GivePlayerMoney(playerid,-2000); // Give the player $-900 return 1; } case 4: // List item 4 { if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,24,25); // Give the player the weapon GivePlayerMoney(playerid,-2500); // Give the player $-900 return 1; } } } } case 3: // LSB Dealer { if(response) // If the player didn't cancel the dialog { switch(listitem) // Switch through the list items, quicker and is easier for adding more guns to the dialog { case 0: // List item 0 { if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,22,100); // Give the player the weapon GivePlayerMoney(playerid,-500); // Give the player $-500 return 1; } case 1: // List item 1 { if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,32,200); // Give the player the weapon GivePlayerMoney(playerid,-1000); // Give the player $-900 return 1; } case 2: // List item 2 { if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,28,100); // Give the player the weapon GivePlayerMoney(playerid,-1000); // Give the player $-900 return 1; } case 3: // List item 3 { if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,25,100); // Give the player the weapon GivePlayerMoney(playerid,-2000); // Give the player $-900 return 1; } case 4: // List item 4 { if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,24,100); // Give the player the weapon GivePlayerMoney(playerid,-2500); // Give the player $-900 return 1; } } } } case 4: // LSV Dealer { if(response) // If the player didn't cancel the dialog { switch(listitem) // Switch through the list items, quicker and is easier for adding more guns to the dialog { case 0: // List item 0 { if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,22,100); // Give the player the weapon GivePlayerMoney(playerid,-500); // Give the player $-500 return 1; } case 1: // List item 1 { if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,32,200); // Give the player the weapon GivePlayerMoney(playerid,-1000); // Give the player $-900 return 1; } case 2: // List item 2 { if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,28,100); // Give the player the weapon GivePlayerMoney(playerid,-1000); // Give the player $-900 return 1; } case 3: // List item 3 { if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,25,100); // Give the player the weapon GivePlayerMoney(playerid,-2000); // Give the player $-900 return 1; } case 4: // List item 4 { if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid,COLOR_RED,"SERVER: You cannot afford this weapon!"); GivePlayerWeapon(playerid,24,100); // Give the player the weapon GivePlayerMoney(playerid,-2500); // Give the player $-900 return 1; } } } } } return 1; } public OnPlayerSpawn(playerid) { SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 50); SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 40); SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 200); SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 200); SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 200); return 1; }