15.05.2010, 16:43
Quit spamming,
That's an example, you should be able to convert your current /buy with what I've given you.
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp(cmdtext,"/buy",true))
{
ShowPlayerDialog(playerid,13337,DIALOG_STYLE_LIST,"Store","Medkit -$500\nM4-$1000","Buy","Close");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
InventoryOnDialogResponse(playerid, dialogid, response, inputtext);
if(dialogid==13337)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid)<500)SendClientMessage(playerid,0xFF0000FF,"You do not have enough cash!");
else{
GivePlayerMoney(playerid,-500);
AddItem(playerid,"Medkit",1);
}
ShowPlayerDialog(playerid,13337,DIALOG_STYLE_LIST,"Store","Medkit -$500\nM4-$1000","Buy","Close");
return 1;
}
case 1:
{
if(GetPlayerMoney(playerid)<1000)SendClientMessage(playerid,0xFF0000FF,"You do not have enough cash!");
else{
GivePlayermoney(playerid,-1000);
AddItem(playerid,"M4 Assault Rifle",1);
}
ShowPlayerDialog(playerid,13337,DIALOG_STYLE_LIST,"Store","Medkit -$500\nM4-$1000","Buy","Close");
return 1;
}
}
}
}
return 1;
}
public OnPlayerUseItem(playerid,ItemName[])
{
if(!PlayerHasItem(playerid,ItemName))return SendClientMessage(playerid,0xFF0000FF,"You no longer have that item!");
if(!strcmp(ItemName,"Medkit",true))
{
new Float:hp;
GetPlayerHealth(playerid,hp);
if(hp>=100)return SendClientMessage(playerid,0xFF0000FF,"You have full health.");
if(hp>75)SetPlayerHealth(playerid,100);
else SetPlayerHealth(playerid,hp+25);
RemoveItem(playerid,ItemName,1);
return SendClientMessage(playerid,0xFF0000FF,"You've used a medkit.");
}
if(!strcmp(ItemName,"M4 Assault Rifle",true))
{
GivePlayerWeapon(playerid,31,30);
RemoveItem(playerid,ItemName,1);
return SendClientMessage(playerid,0xFF0000FF,"You pulled out an M4.");
}
return 0;
}