CMDellmats(playerid, params[]) { if(Player[playerid][Admin] >= 1) { SendClientMessage(playerid,COLOR_WHITE, "Administrators can't use this command."); return 1; } new string[128]; if(GetPVarInt(playerid, "SellMatsTimer") > 0) { format(string, sizeof(string), "You must wait %d seconds before selling more materials.", GetPVarInt(playerid, "SellMatsTimer")); SendClientMessage(playerid, COLOR_GREY, string); return 1; } new giveplayerid, amount, material[1], price; if(sscanf(params, "udud", giveplayerid, material, amount, price)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellmats [playerid/partofname] [material] [amount] [price]"); if(amount < 1) { SendClientMessage(playerid, COLOR_GREY, "Materials amount must be no lower than 1!"); return 1; } if (material != "a" || material != "A" || material != "b" || material != "B" || material != "c" || material != "C") { SendClientMessage(playerid, COLOR_GREY, "Invalid material class."); return 1; } if(price < 5000) { SendClientMessage(playerid, COLOR_GREY, "Price must be no lower than $5000."); return 1; } if(amount > Player[playerid][MatsA] || amount > Player[playerid][MatsB] || amount > Player[playerid][MatsC]) { SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!"); return 1; } if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { if(ProxDetectorS(8.0, playerid, giveplayerid)) { if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "You can't sell materials to yourself!"); return 1; } format(string, sizeof(string), "* You offered %s to buy %d class %s materials for $%d.", GetPlayerName(giveplayerid), amount, material, price); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "* %s wants to sell you %d class %s materials for $%d, (type /accept mats) to buy.", GetPlayerName(playerid), amount, material, price); SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string); SetPVarInt(playerid, "SellMatsTimer", 30); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_SELLMATSTIMER); MatsOffer[giveplayerid] = playerid; MatsPrice[giveplayerid] = price; MatsType[giveplayerid] = material; MatsAmount[giveplayerid] = amount; } else { SendClientMessage(playerid, COLOR_GREY, "That player isn't near you."); } } } else { SendClientMessage(playerid, COLOR_GREY, "Invalid player specified."); } return 1; } |
CMD:sellmats(playerid,params[])
{
if(Player[playerid][Admin] >= 1)return SendClientMessage(playerid,COLOR_WHITE,"Administrators can't use this command.");
new string[145];
if(GetPVarInt(playerid,"SellMatsTimer") > 0)
{
format(string,sizeof string,"You must wait %d seconds before selling more materials.",GetPVarInt(playerid,"SellMatsTimer"));
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
new giveplayerid,amount,material[2],price;
if(sscanf(params,"us[2]dd",giveplayerid,material,amount,price))return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /sellmats [playerid / partofname] [material] [amount] [price]");
if(amount < 1)return SendClientMessage(playerid,COLOR_GREY,"Materials amount must be no lower than 1!");
if(price < 5000)return SendClientMessage(playerid, COLOR_GREY, "Price must be no lower than $5000.");
if(!strcmp(material,"A",true))if(amount > Player[playerid][MatsA])return SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!");
else if(!strcmp(material,"B",true))if(amount > Player[playerid][MatsB])return SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!");
else if(!strcmp(material,"C",true))if(amount > Player[playerid][MatsC])return SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!");
else SendClientMessage(playerid, COLOR_GREY, "Invalid material class.");
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(giveplayerid == playerid)return SendClientMessage(playerid, COLOR_GREY, "You can't sell materials to yourself!");
if(ProxDetectorS(8.0,playerid,giveplayerid))
{
new givename[MAX_PLAYER_NAME],myname[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid,givename,sizeof(givename));
GetPlayerName(playerid,myname,sizeof(myname));
format(string,sizeof string,"* You affered %s to buy %d class %s materials for $%d.",givename,amount,material,price);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
format(string,sizeof string,"* %s wants to sell you %d class %s materials for $%d. (type /accept mats - to buy)",myname,amount,material,price);
SendClientMessage(giveplayerid,COLOR_LIGHTBLUE,string);
SetPVarInt(playerid,"SellMatsTimer",30);
SetTimerEx("OtherTimerEx",1000,false,"ii",playerid,TYPE_SELLMATSTIMER);
MatsOffer[giveplayerid] = playerid;
MatsPrice[giveplayerid] = price;
MatsType[giveplayerid] = material;
MatsAmount[giveplayerid] = amount;
}
else return SendClientMessage(playerid, COLOR_GREY, "That player isn't near you.");
}
else return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified.");
}
return 1;
}
MatsType[giveplayerid] = material; |
MatsType[giveplayerid] = material;
format(MatsType[giveplayerid],2,"%s",material);
new MatsType[MAX_PLAYERS][2];
CMD:accept(playerid, params[])
{
if(Player[playerid][Admin] >= 1)
{
SendClientMessage(playerid,COLOR_WHITE, "Administrators can't use this command.");
return 1;
}
new string[145];
//new sendername[MAX_PLAYER_NAME];
//new giveplayer[MAX_PLAYER_NAME];
new material[2];
if(IsPlayerConnected(playerid))
{
if(isnull(params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /accept [name]");
SendClientMessage(playerid, COLOR_GREY, "Available Names: Mats");
return 1;
}
else if(strcmp(params,"mats",true) == 0)
{
if(MatsOffer[playerid] < 999)
{
if(GetPlayerMoney(playerid) >= MatsPrice[playerid])
{
if(IsPlayerConnected(MatsOffer[playerid]))
{
if(GetPVarInt(playerid, "SellMatsTimer") > 0)
{
format(string, sizeof(string), "You must wait %d seconds before accepting materials.", GetPVarInt(playerid, "SellMatsTimer"));
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
if (Player[MatsOffer[playerid]][MatsA] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if (Player[MatsOffer[playerid]][MatsB] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if (Player[MatsOffer[playerid]][MatsC] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
format(string, sizeof(string), "* You bought %d class %s materials for $%d from %s.", MatsAmount[playerid], material, MatsPrice[playerid], GetName(MatsOffer[playerid]));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has bought your %d class %s materials, the $%d was added to your money.", GetName(playerid), MatsAmount[playerid], material, MatsPrice[playerid]);
SendClientMessage(MatsOffer[playerid], COLOR_LIGHTBLUE, string);
GivePlayerMoney(MatsOffer[playerid], MatsPrice[playerid]);
GivePlayerMoney(playerid, -MatsPrice[playerid]);
if (strcmp(material, "A", true))
{
Player[playerid][MatsA] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsA] -= MatsAmount[playerid];
}
else if (strcmp(material, "B", true))
{
Player[playerid][MatsB] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsB] -= MatsAmount[playerid];
}
else if (strcmp(material, "C", true))
{
Player[playerid][MatsC] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsC] -= MatsAmount[playerid];
}
MatsOffer[playerid] = 999;
MatsPrice[playerid] = 0;
MatsType[playerid] = 0;
MatsAmount[playerid] = 0;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You can't afford those materials!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "No-one offered you any materials!");
return 1;
}
}
}
return 1;
}
CMD:accept(playerid, params[])
{
if(Player[playerid][Admin] >= 1)
{
SendClientMessage(playerid,COLOR_WHITE, "Administrators can't use this command.");
return 1;
}
new string[145];
//new sendername[MAX_PLAYER_NAME];
//new giveplayer[MAX_PLAYER_NAME];
new material[2];
if(IsPlayerConnected(playerid))
{
if(isnull(params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /accept [name]");
SendClientMessage(playerid, COLOR_GREY, "Available Names: Mats");
return 1;
}
else if(strcmp(params,"mats",true) == 0)
{
if(MatsOffer[playerid] < 999)
{
if(GetPlayerMoney(playerid) >= MatsPrice[playerid])
{
if(IsPlayerConnected(MatsOffer[playerid]))
{
if(GetPVarInt(playerid, "SellMatsTimer") > 0)
{
format(string, sizeof(string), "You must wait %d seconds before accepting materials.", GetPVarInt(playerid, "SellMatsTimer"));
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
if (Player[MatsOffer[playerid]][MatsA] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if (Player[MatsOffer[playerid]][MatsB] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if (Player[MatsOffer[playerid]][MatsC] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
format(string, sizeof(string), "* You bought %d class %s materials for $%d from %s.", MatsAmount[playerid], material, MatsPrice[playerid], GetName(MatsOffer[playerid]));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has bought your %d class %s materials, the $%d was added to your money.", GetName(playerid), MatsAmount[playerid], material, MatsPrice[playerid]);
SendClientMessage(MatsOffer[playerid], COLOR_LIGHTBLUE, string);
GivePlayerMoney(MatsOffer[playerid], MatsPrice[playerid]);
GivePlayerMoney(playerid, -MatsPrice[playerid]);
if (strcmp(material, "A", true))
{
Player[playerid][MatsA] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsA] -= MatsAmount[playerid];
}
else if (strcmp(material, "B", true))
{
Player[playerid][MatsB] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsB] -= MatsAmount[playerid];
}
else if (strcmp(material, "C", true))
{
Player[playerid][MatsC] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsC] -= MatsAmount[playerid];
}
MatsOffer[playerid] = 999;
MatsPrice[playerid] = 0;
MatsType[playerid] = 0;
MatsAmount[playerid] = 0;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You can't afford those materials!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "No-one offered you any materials!");
return 1;
}
}
}
return 1;
}
CMD:sellmats(playerid,params[])
{
if(Player[playerid][Admin] >= 1)return SendClientMessage(playerid,COLOR_WHITE,"Administrators can't use this command.");
new string[145];
if(GetPVarInt(playerid,"SellMatsTimer") > 0)
{
format(string,sizeof string,"You must wait %d seconds before selling more materials.",GetPVarInt(playerid,"SellMatsTimer"));
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
new giveplayerid,amount,material[2],price;
if(sscanf(params,"us[2]dd",giveplayerid,material,amount,price))return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /sellmats [playerid / partofname] [material] [amount] [price]");
if(amount < 1)return SendClientMessage(playerid,COLOR_GREY,"Materials amount must be no lower than 1!");
if(price < 5000)return SendClientMessage(playerid, COLOR_GREY, "Price must be no lower than $5000.");
if(!strcmp(material,"A",true))if(amount > Player[playerid][MatsA])return SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!");
else if(!strcmp(material,"B",true))if(amount > Player[playerid][MatsB])return SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!");
else if(!strcmp(material,"C",true))if(amount > Player[playerid][MatsC])return SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!");
else SendClientMessage(playerid, COLOR_GREY, "Invalid material class.");
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(giveplayerid == playerid)return SendClientMessage(playerid, COLOR_GREY, "You can't sell materials to yourself!");
if(ProxDetectorS(8.0,playerid,giveplayerid))
{
new givename[MAX_PLAYER_NAME],myname[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid,givename,sizeof(givename));
GetPlayerName(playerid,myname,sizeof(myname));
format(string,sizeof string,"* You affered %s to buy %d class %s materials for $%d.",givename,amount,material,price);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
format(string,sizeof string,"* %s wants to sell you %d class %s materials for $%d. (type /accept mats - to buy)",myname,amount,material,price);
SendClientMessage(giveplayerid,COLOR_LIGHTBLUE,string);
SetPVarInt(playerid,"SellMatsTimer",30);
SetTimerEx("OtherTimerEx",1000,false,"ii",playerid,TYPE_SELLMATSTIMER);
MatsOffer[giveplayerid] = playerid;
MatsPrice[giveplayerid] = price;
format(MatsType[giveplayerid],2,"%s",material);
MatsAmount[giveplayerid] = amount;
}
else return SendClientMessage(playerid, COLOR_GREY, "That player isn't near you.");
}
else return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified.");
}
return 1;
}
CMD:accept(playerid,params[])
{
if(Player[playerid][Admin] >= 1)return SendClientMessage(playerid,COLOR_WHITE, "Administrators can't use this command.");
new string[145];
if(isnull(params))
{
SendClientMessage(playerid,COLOR_WHITE,"USAGE: /accept [name]");
SendClientMessage(playerid,COLOR_GREY,"Available Names: Mats");
return 1;
}
if(!strcmp(params,"mats",true))
{
if(MatsOffer[playerid] == 999)return SendClientMessage(playerid, COLOR_GREY, "No-one offered you any materials!");
if(GetPlayerMoney(playerid) < MatsPrice[playerid])return SendClientMessage(playerid, COLOR_GREY, "You can't afford those materials!");
if(IsPlayerConnected(MatsOffer[playerid]))
{
if(GetPVarInt(playerid,"SellMatsTimer") > 0)
{
format(string,sizeof string,"You must wait %d seconds before accepting materials.",GetPVarInt(playerid,"SellMatsTimer"));
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
if(Player[MatsOffer[playerid]][MatsA] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if(Player[MatsOffer[playerid]][MatsB] < MatsAmount[playerid]))
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if(Player[MatsOffer[playerid]][MatsC] < MatsAmount[playerid]))
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
format(string, sizeof(string), "* You bought %d class %s materials for $%d from %s.", MatsAmount[playerid], MatsType[playerid], MatsPrice[playerid], GetName(MatsOffer[playerid]));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has bought your %d class %s materials, the $%d was added to your money.", GetName(playerid), MatsAmount[playerid], MatsType[playerid], MatsPrice[playerid]);
SendClientMessage(MatsOffer[playerid], COLOR_LIGHTBLUE, string);
GivePlayerMoney(MatsOffer[playerid], MatsPrice[playerid]);
GivePlayerMoney(playerid, -MatsPrice[playerid]);
if(!strcmp(MatsType[playerid],"A",true))
{
Player[playerid][MatsA] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsA] -= MatsAmount[playerid];
}
else if(!strcmp(MatsType[playerid],"B",true))
{
Player[playerid][MatsB] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsB] -= MatsAmount[playerid];
}
else if(!strcmp(MatsType[playerid],"C",true))
{
Player[playerid][MatsC] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsC] -= MatsAmount[playerid];
}
MatsOffer[playerid] = 999;
MatsPrice[playerid] = 0;
format(MatsType[playerid],2,"");
MatsAmount[playerid] = 0;
}
}
return 1;
}
That player does not have that amount of materials anymore!