23.03.2017, 21:11
Yes, of course.
This is a global variable:
And this is your code.
This is a global variable:
PHP код:
new playerGiveItem[MAX_PLAYERS]; //under the includes
PHP код:
CMD:giveitem(playerid,params[])
{
new player1;
if(IsMuted(playerid))return 1;
{
if(sscanf(params,"u",player1)) return SendClientMessage(playerid,GREY,"USAGE: /giveitem [playerid]");
if(!IsPlayerConnectedEx(player1) || player1==playerid)return SendClientMessage(playerid,GREY,"Invalid player ID");
ShowInventoryTrade(playerid);
playerGiveItem[playerid] = player1;
}
return 1;
}
//==============================================================================
public OnPlayerModelSelectionEx(playerid, response, extraid, modelid)
{
if(extraid == INVENTORY_TRADE)
{
if(response)
{
if(modelid == 18631) return SendClientMessage(playerid,-1,"There slot does not have any item. ");
if(modelid == 346)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a 9mm to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 331)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a set of brass knuckles to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 347)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Silenced 9mm to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 348)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Desert Eagle to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 349)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Shotgun to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 350)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Sawed-off Shotgun to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 351)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a SPAS-12 Shotgun to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 352)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Uzi to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 353)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a MP5 to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 355)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a AK-47 to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 356)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a M4 to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 372)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a TEC-9 to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 357)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Rifle to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 358)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Sniper Rifle to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 371)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Parachute to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 335)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Knife to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 336)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Baseball bat to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 337)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Spade to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 367)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Camera to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 19921)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Toolkit to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 11738)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave a Medkit to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 11736)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave some bandages to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
if(modelid == 325)
{
new str[128];
format(str,sizeof(str),"%s(%i) gave some flowers to %s(%i)",PlayerName(playerid),playerid,PlayerName(playerGiveItem[playerid]),playerGiveItem[playerid]);
SendNearbyMessage(playerid,30.0,str,ORANGE);
RemoveItem(playerid,modelid);
AddItem(playerGiveItem[playerid],modelid);
}
}
else SendClientMessage(playerid, 0xFF0000FF, "Trading canceled");
}
return 1;
}
//==============================================================================
stock ShowInventoryTrade(playerid)
{
new iteminv[21];
for(new i = 0; i < 20;i++)
{
iteminv[i] = InvInfo[playerid][iSlot][i];
if(InvInfo[playerid][iSlot][i] == 0)
{
iteminv[i] = 18631;
}
}
ShowModelSelectionMenuEx(playerid, iteminv,20, "Inventory",INVENTORY_TRADE, 0.0, 0.0,0.0);
return 1;
}