19.09.2009, 09:32
I need command to give other players mats cracks etc. with command /give. Can ya help me?
Thanks Mauka4
Thanks Mauka4
if(strcmpEx(cmd, "/give", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /give [playerid] [value] [amount]");
SendClientMessage(playerid, COLOR_GREY, "materials | drugs | products | rope | rags");
return 1;
}
new giveplayerid2;
GetPlayerName(giveplayerid2, sendername, sizeof(sendername));
giveplayerid2 = ReturnUser(tmp);
giveplayerid = ReturnUser(tmp);
//new playur;
//playur = strval(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /give [playerid] [value] [amount]");
SendClientMessage(playerid, COLOR_GREY, "materials | drugs | products | rope | rags");
return 1;
}
new stat[32];
strmid(stat, tmp, 0, sizeof(stat), sizeof(stat));
//stat = memcpy(stat, tmp, 0, 32*4, 32*4);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /give [playerid] [value] [amount]");
SendClientMessage(playerid, COLOR_GREY, "materials | drugs | products | rope | rags");
return 1;
}
new amount;
amount = strval(tmp);
if(amount < 1)
{
SendClientMessage(playerid, COLOR_WHITE, "That is not an acceptable amount.");
return 1;
}
if (!ProxDetectorS(5.0, playerid, giveplayerid2))
{
SendClientMessage(playerid, COLOR_WHITE, "You're too far away!");
return 1;
}
if (strcmpEx(stat, "rags", true) == 0)
{
if(pStats[playerid][pRags] >= amount)
{
format(string, sizeof(string), "%s has given you %d rags (using /give).", GetPlayerNameEx(playerid), amount);
SendClientMessage(giveplayerid2, COLOR_LIGHTBLUE, string);
pStats[giveplayerid2][pRags] += amount;
pStats[playerid][pRags] -= amount;
format(string, sizeof(string), "You have successfully given %d rags, to %s.", amount, GetPlayerNameEx(giveplayerid2));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You do not have enough rags to complete this transaction.");
return 1;
}
}
if (strcmpEx(stat, "materials", true) == 0)
{
if(pStats[playerid][pMaterials] >= amount)
{
if(pStats[giveplayerid2][pMaterials] >= 2000)
{
SendClientMessage(giveplayerid2, COLOR_WHITE, "You must deposit some materials, as you're unable to carry more than 2000");
SendClientMessage(playerid, COLOR_WHITE, "That person is unable to carry any more materials.");
return 1;
}
format(string, sizeof(string), "%s has given you %d materials (using /give).", GetPlayerNameEx(playerid), amount);
SendClientMessage(giveplayerid2, COLOR_LIGHTBLUE, string);
pStats[giveplayerid2][pMaterials] += amount;
pStats[playerid][pMaterials] -= amount;
format(string, sizeof(string), "You have successfully given %d materials, to %s.", amount, GetPlayerNameEx(giveplayerid2));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You do not have enough materials to complete this transaction.");
return 1;
}
}
if (strcmpEx(stat, "rope", true) == 0)
{
if(pStats[playerid][pRope] >= amount)
{
format(string, sizeof(string), "%s has given you %d rope (using /give).", GetPlayerNameEx(playerid), amount);
SendClientMessage(giveplayerid2, COLOR_LIGHTBLUE, string);
pStats[giveplayerid2][pRope] += amount;
pStats[playerid][pRope] -= amount;
format(string, sizeof(string), "You have successfully given %d rope to %s.", amount, GetPlayerNameEx(giveplayerid2));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You do not have enough rope to complete this transaction.");
return 1;
}
}
if (strcmpEx(stat, "drugs", true) == 0)
{
if(pStats[playerid][pDrugs] >= amount)
{
format(string, sizeof(string), "%s has given you %d drugs (using /give).", GetPlayerNameEx(playerid), amount);
SendClientMessage(giveplayerid2, COLOR_LIGHTBLUE, string);
pStats[giveplayerid2][pDrugs] += amount;
pStats[playerid][pDrugs] -= amount;
format(string, sizeof(string), "You have successfully given %d drugs, to %s.", amount, GetPlayerNameEx(giveplayerid2));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You do not have enough drugs to complete this transaction.");
return 1;
}
}
if (strcmpEx(stat, "products", true) == 0)
{
if(pStats[playerid][pProducts] >= amount)
{
format(string, sizeof(string), "%s has given you %d products (using /give).", GetPlayerNameEx(playerid), amount);
SendClientMessage(giveplayerid2, COLOR_LIGHTBLUE, string);
pStats[giveplayerid2][pProducts] += amount;
pStats[playerid][pProducts] -= amount;
format(string, sizeof(string), "You have successfully given %d products, to %s.", amount, GetPlayerNameEx(giveplayerid2));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You do not have enough products to complete this transaction.");
return 1;
}
}
}
}
}
return 1;
}