23.01.2015, 22:14
how i can create ammo shop ,when player buy ammo he get + 100 bullets for all weapons??
stock GivePlayerAmmoForAllWeaps(playerid, ammo)
{
if(ammo < 1 || !IsPlayerConnected(playerid))
return 0;
new _w[2];
for(new i; i<12;i++)
{
GetPlayerWeaponData(playerid,i, _w[0], _w[1]);
if(!weap[0])
continue;
SetPlayerAmmo(playerid, _w[0], _w[1]+ammo);
}
return 1;
}
#include <a_samp>
#define DIALOG_SHOP 8
#define COLOR_RED 0xFF0000FF
#define COLOR_GREEN 0x00FF00FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_PURPLE 0xFF00FFAA
#define ORANGE 0xFF8000AA
#define COLOR_BLUE 0x0000FFFF
#define COLOR_ORANGE 0xFF9000FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_DARKBLUE 0x00007AFF
#define COLOR_PINK 0xFF007AFF
#define COLOR_BLACK 0x000000FF
#define COLOR_LIGHTGREEN 0x82FF82FF
#define lightblue 0x33CCFFAA
#define red 0xFF0000AA
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/shop", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid,DIALOG_SHOP,DIALOG_STYLE_LIST,"Shop:","{00ff21}AK - 47{ffff00}(1000$)\n{00ff21}Knife{ffff00}(100$)\n{00ff21}Spraycan{ffff00}(300$)\n{00ff21}Parachute{ffff00}(100$)","Buy","Cancel");
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_SHOP)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_RED,"You don't have enough money to buy this!");
GivePlayerWeapon(playerid,30,100);
GivePlayerMoney(playerid,-1000);
}
case 1:
{
if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,COLOR_RED,"You don't have enough money to buy this!");
GivePlayerWeapon(playerid,4,1);
GivePlayerMoney(playerid,-100);
}
case 2:
{
if(GetPlayerMoney(playerid) < 300) return SendClientMessage(playerid,COLOR_RED,"You don't have enough money to buy this!");
GivePlayerWeapon(playerid,41,30);
GivePlayerMoney(playerid,-300);
}
case 3:
{
if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,COLOR_RED,"You don't have enough money to buy this!");
GivePlayerWeapon(playerid,46,1);
GivePlayerMoney(playerid,-100);
}
}
}
}
return 0;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}