Can someone change this to a dialog, when you type /buy in a business it opens the menu,
PHP код:
CMD:buy(playerid, params[])
{
new idx = GetPlayerVirtualWorld(playerid)-100, string[128], type, price;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_DARKRED, "You need to login first before using any command.");
if(idx > 0 && idx < MAX_BIZ && BizInfo[idx][bType] != 1 && BizInfo[idx][bType] != 2 && BizInfo[idx][bType] != 3 && BizInfo[idx][bType] != 4 && BizInfo[idx][bType] != 6 || idx < 1 || idx > MAX_BIZ) return SendClientMessage(playerid, COLOR_DARKRED, "You are not inside a business.");
if(BizInfo[idx][bType] == 1)
{
if(sscanf(params, "s[32]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [item]");
if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_DARKRED, "This business is currently out of products.");
if(!strcmp(params, "cellphone", true))
{
if(PlayerInfo[playerid][pMoney] < 100) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
new randphone = random(100) + random(8999);//minimum 100 max 9999
PlayerInfo[playerid][pNumber] = randphone;
PlayerInfo[playerid][pHasCellphone] = 1;
BizInfo[idx][bMoney] += 100;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -100);
format(string, sizeof(string), "* %s has bought a cellphone for $100.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " (( Check /stats to check your new Phone Number ))");
}
if(!strcmp(params, "phonebook", true))
{
if(PlayerInfo[playerid][pMoney] < 50) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pPhonebook] = 1;
BizInfo[idx][bMoney] += 50;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -50);
format(string, sizeof(string), "* %s has bought an electronic phonebook for $50.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /phonebook to find someone's number.");
}
if(!strcmp(params, "dice", true))
{
if(PlayerInfo[playerid][pMoney] < 20) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pDice] = 1;
BizInfo[idx][bMoney] += 20;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -20);
format(string, sizeof(string), "* %s has bought a pair of special dice for $20.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /rolldice to roll a dice.");
}
if(!strcmp(params, "cigar", true))
{
if(PlayerInfo[playerid][pMoney] < 100) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pCigar] = 5;
BizInfo[idx][bMoney] += 100;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -100);
format(string, sizeof(string), "* %s has bought 5 cuban cigars for $100.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /use to smoke a cigar.");
}
// Level 2: Speedometer | Sprunk | Spraycan | Rope
if(!strcmp(params, "speedometer", true))
{
if(PlayerInfo[playerid][pMoney] < 200) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pSpeedo] = 1;
BizInfo[idx][bMoney] += 200;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -200);
format(string, sizeof(string), "* %s has bought a speedometer for $200.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /tog to toggle speedometer on/off.");
}
if(!strcmp(params, "sprunk", true))
{
if(PlayerInfo[playerid][pMoney] < 30) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pSprunk] = 5;
BizInfo[idx][bMoney] += 30;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -30);
format(string, sizeof(string), "* %s has bought 5 redbull cans for $30.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /sprunk to drink a sprunk can.");
}
if(!strcmp(params, "spraycan", true))
{
if(PlayerInfo[playerid][pMoney] < 100) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pSpray] = 10;
BizInfo[idx][bMoney] += 100;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -100);
format(string, sizeof(string), "* %s has bought a duko spraycan $100.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /colorcar & /paintcar to color/paint a car.");
}
if(!strcmp(params, "rope", true))
{
if(PlayerInfo[playerid][pMoney] < 60) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pRope] = 5;
BizInfo[idx][bMoney] += 60;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -60);
format(string, sizeof(string), "* %s has bought 5 strong ropes for $60.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /tie to tie someone.");
}
// Level 3: Blindfold | WalkieTalkie
if(!strcmp(params, "blindfold", true))
{
if(PlayerInfo[playerid][pMoney] < 60) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pBlindfold] = 5;
BizInfo[idx][bMoney] += 60;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -60);
format(string, sizeof(string), "* %s has bought 5 blindfolds for $600.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /blindfold to blindfold someone.");
}
if(!strcmp(params, "walkietalkie", true))
{
if(PlayerInfo[playerid][pMoney] < 200) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pWT] = 1;
BizInfo[idx][bMoney] += 200;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -200);
format(string, sizeof(string), "* %s has bought a WalkieTalkie for $200.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /wtc to adjust the WalkieTalkie's channel, /wt to talk on it.");
}
if(!strcmp(params, "smartphone", true))
{
if(PlayerInfo[playerid][pMoney] < 500) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pHasCellphone] = 2;
BizInfo[idx][bMoney] += 500;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -500);
format(string, sizeof(string), "* %s has bought a smartphone for $500.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /smartphone to view your new cellphone commands.");
}
// Level 4: Camera | Gas
if(!strcmp(params, "camera", true))
{
if(PlayerInfo[playerid][pMoney] < 300) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
GiveDodWeapon(playerid, 43, 999999);
BizInfo[idx][bMoney] += 300;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -300);
format(string, sizeof(string), "* %s has bought a professional camera for $300.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can start taking photos using your camera.");
}
if(!strcmp(params, "gascan", true))
{
if(PlayerInfo[playerid][pMoney] < 100) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pGas] = 1;
BizInfo[idx][bMoney] += 100;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -100);
format(string, sizeof(string), "* %s has bought a gas can for $100.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /gascan inside a vehicle anywhere now.");
}
// Level 5: Radio
/*if(!strcmp(params, "radio", true))
{
if(BizInfo[idx][bLevel] < 2) return SendClientMessage(playerid, COLOR_DARKRED, "This 24/7 Market doesn't have this product yet.");
if(PlayerInfo[playerid][pMoney] < 600) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
PlayerInfo[playerid][pRadio] = 1;
BizInfo[idx][bMoney] += 600;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
GiveDodMoney(playerid, -600);
format(string, sizeof(string), "* %s has bought a radio for $600.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SendClientMessage(playerid, COLOR_WHITE, " You can use /music to play music using your radio.");
}*/
}
else if(BizInfo[idx][bType] == 3)
{
if(sscanf(params, "i", type)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [type]");
if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_DARKRED, "This business is currently out of products.");
if(type == 1) price = 400;
else if(type == 2) price = 2000;
else if(type == 3) price = 800;
else if(type == 4) price = 1200;
else if(type == 5) price = 2200;
else if(type == 6) price = 1000;
else if(type == 7) price = 5000;
if(type < 1 || type > 7) return SendClientMessage(playerid, COLOR_DARKRED, "Products are between 1 and 7");
if(PlayerInfo[playerid][pMoney] < price) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
switch(type)
{
case 1:
{
if(GetPlayerWeapon(playerid) != 25 && GetPlayerWeapon(playerid) != 26 && GetPlayerWeapon(playerid) != 27) return SendClientMessage(playerid, COLOR_DARKRED, "You are not holding the right weapon for this type of ammo.");
if(GetPlayerWeapon(playerid) == 25) GiveDodWeapon(playerid, 25, 120);
if(GetPlayerWeapon(playerid) == 26) GiveDodWeapon(playerid, 26, 120);
if(GetPlayerWeapon(playerid) == 27) GiveDodWeapon(playerid, 27, 120);
format(string, sizeof(string), "* %s has bought 120 shotgun bullets for $%d.", RPN(playerid), price);
}
case 2:
{
if(GetPlayerWeapon(playerid) != 33 && GetPlayerWeapon(playerid) != 34) return SendClientMessage(playerid, COLOR_DARKRED, "You are not holding the right weapon for this type of ammo.");
if(GetPlayerWeapon(playerid) == 33) GiveDodWeapon(playerid, 33, 200);
if(GetPlayerWeapon(playerid) == 34) GiveDodWeapon(playerid, 34, 200);
format(string, sizeof(string), "* %s has bought 100 rifle bullets for $%d.", RPN(playerid), price);
}
case 3:
{
if(GetPlayerWeapon(playerid) != 22 && GetPlayerWeapon(playerid) != 23 && GetPlayerWeapon(playerid) != 24) return SendClientMessage(playerid, COLOR_DARKRED, "You are not holding the right weapon for this type of ammo.");
if(GetPlayerWeapon(playerid) == 22) GiveDodWeapon(playerid, 22, 120);
if(GetPlayerWeapon(playerid) == 23) GiveDodWeapon(playerid, 23, 120);
if(GetPlayerWeapon(playerid) == 24) GiveDodWeapon(playerid, 24, 120);
format(string, sizeof(string), "* %s has bought 120 gun bullets for $%d.", RPN(playerid), price);
}
case 4:
{
if(GetPlayerWeapon(playerid) != 28 && GetPlayerWeapon(playerid) != 29 && GetPlayerWeapon(playerid) != 32) return SendClientMessage(playerid, COLOR_DARKRED, "You are not holding the right weapon for this type of ammo.");
if(GetPlayerWeapon(playerid) == 28) GiveDodWeapon(playerid, 28, 200);
if(GetPlayerWeapon(playerid) == 29) GiveDodWeapon(playerid, 29, 200);
if(GetPlayerWeapon(playerid) == 32) GiveDodWeapon(playerid, 32, 200);
format(string, sizeof(string), "* %s has bought 200 light-machinegun bullets for $%d.", RPN(playerid), price);
}
case 5:
{
if(GetPlayerWeapon(playerid) != 30 && GetPlayerWeapon(playerid) != 31) return SendClientMessage(playerid, COLOR_DARKRED, "You are not holding the right weapon for this type of ammo.");
if(GetPlayerWeapon(playerid) == 30) GiveDodWeapon(playerid, 30, 200);
if(GetPlayerWeapon(playerid) == 31) GiveDodWeapon(playerid, 31, 200);
format(string, sizeof(string), "* %s has bought 200 heavy-machinegun bullets for $%d.", RPN(playerid), price);
}
case 6:
{
new Float:Armour; GetPlayerArmour(playerid, Armour);
if(Armour >= 80) return SendClientMessage(playerid, COLOR_DARKRED, "You don't need a vest.");
SetPlayerArmour(playerid, 80);
format(string, sizeof(string), "* %s has bought a vest for $%d.", RPN(playerid), price);
}
}
GiveDodMoney(playerid, -price);
BizInfo[idx][bMoney] += price;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
return 1;
}
else if(BizInfo[idx][bType] == 4)
{
if(sscanf(params, "i", type)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [type]");
if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_DARKRED, "This business is currently out of products.");
if(type == 1) price = 50;
else if(type == 2) price = 100;
else if(type == 3) price = 200;
if(PlayerInfo[playerid][pMoney] < price) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
switch(type)
{
case 1:
{
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_SPRUNK);
format(string, sizeof(string), "* %s has bought a sprunk can $%d.", RPN(playerid), price);
}
case 2:
{
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER);
format(string, sizeof(string), "* %s has bought a bottle of beer for $%d.", RPN(playerid), price);
}
case 3:
{
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_WINE);
format(string, sizeof(string), "* %s has bought a bottle of vodka for $%d.", RPN(playerid), price);
}
}
GiveDodMoney(playerid, -price);
BizInfo[idx][bMoney] += price;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
else if(BizInfo[idx][bType] == 6)
{
if(sscanf(params, "i", type)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [type]");
if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_DARKRED, "This business is currently out of products.");
if(type == 1) price = 10;
else if(type == 2) price = 30;
else if(type == 3) price = 50;
if(PlayerInfo[playerid][pMoney] < price) return SendClientMessage(playerid, COLOR_DARKRED, "You don't have enough money to do this.");
new Float:pH;
switch(type)
{
case 1:
{
GetPlayerHealth(playerid, pH);
SetPlayerHealth(playerid, pH+20);
GetPlayerHealth(playerid, pH);
if(pH > 100) SetPlayerHealth(playerid, 100);
format(string, sizeof(string), "* %s has bought a small meal for $%d.", RPN(playerid), price);
}
case 2:
{
GetPlayerHealth(playerid, pH);
SetPlayerHealth(playerid, pH+40);
GetPlayerHealth(playerid, pH);
if(pH > 100) SetPlayerHealth(playerid, 100);
format(string, sizeof(string), "* %s has bought a medium meal for $%d.", RPN(playerid), price);
}
case 3:
{
SetPlayerHealth(playerid, 100);
format(string, sizeof(string), "* %s has bought a large meal for $%d.", RPN(playerid), price);
}
}
GiveDodMoney(playerid, -price);
BizInfo[idx][bMoney] += price;
BizInfo[idx][bProducts] --;
BizInfo[idx][bSold] ++;
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
return 1;
}