sell command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sell command (
/showthread.php?tid=382161)
sell command -
PaulDinam - 02.10.2012
i need a simple sell command to other player ID, with price.
and then he will need to do /accept
Re: sell command -
nmader - 02.10.2012
Alright Paul, first of all you understand this is for help, not for getting someone else to do it. Second of all, what is your preferred command system?
Re: sell command -
PaulDinam - 02.10.2012
like /sellhotdog
/accepthotdog
i need a simple one, so i could learn from it
Re: sell command -
nmader - 02.10.2012
Alright... I will use ZCMD as it is much quicker and much easier for me to use.
pawn Код:
enum PlayerStatistics //All the text in this pawn section goes towards the top of the script.
{
PendingHD,
OfferingHD,
};
new Player[MAX_PLAYERS][PlayerStatistics];
pawn Код:
command(sellhotdog, playerid, params[])
{
new id;
if(sscanf(params, "u", id)) //Basically stating if all they put was /sellhotdog and not the player's ID.
{
SendClientMessage(playerid, -1, "SYNTAX: /sellhotdog [playerid]"); //-1 stands for white, change that with your colors if wanted.
}
else
{
new string[128];
format(string, sizeof(string), "You have offered to sell %s a hotdog!");
SendClientMessage(playerid, -1, string); //The string was defined on the line previous.
Player[id][PendingHD] = 1;
Player[playerid][OfferingHD] = 1;
}
}
pawn Код:
command(accepthotgod, playerid, params[])
{
new id;
if(sscanf(params, "u", id))
{
SendClientMessage(playerid, -1, "SYNTAX: /accepthotdog [sellerid]");
}
else
{
if(Player[playerid][PendingHD] == 1)
{
if(Player[id][OfferingHD] == 1)
{
GivePlayerMoney(playerid, -2); //Subtracting $2 for the hotdog
GivePlayerMoney(id, 2); //Giving $2 for the hotdog to the seller.
}
}
}
return 1;
}
Re: sell command -
gtakillerIV - 02.10.2012
And if you want it to be more better use if(IsPlayerInRangeOfPoint(targetid)).
Re: sell command -
nmader - 02.10.2012
He said he had wanted something basic that isn't too difficult to understand. I could have made it to where the two players have to be within a 2 meter radius. I could have also made it much more difficult but efficient.
Re: sell command -
PaulDinam - 02.10.2012
i made something
Код:
if(strcmp("/sellhotdog", cmd, true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_GRAD1,"{33CCFF}USAGE:{FFFFFF} /sellhotdog [playerid] [price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_GRAD1,"{33CCFF}USAGE:{FFFFFF} /sellhotdog [playerid] [price]");
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
new veh = GetPlayerVehicleID(playerid);
if(PlayerInfo[playerid][pJob] != 3)
{
SendClientMessage(playerid, COLOR_YELLOW2, "You are not a HotDog seller.");
return 1;
}
if(!IsAHotDog(veh))
{
SendClientMessage(playerid, COLOR_YELLOW2, "You must be inside a HotDog van to sell HotDogs.");
return 1;
}
if(giveplayerid != INVALID_PLAYER_ID)
{
new price = strval(tmp);
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_SYSTEM, "You cannot sell a hotdog to yourself");
return 1;
}
if (ProxDetectorS(15.0, playerid, giveplayerid))
{
OfferHotdogPlayer[giveplayerid] = playerid;
OfferHotdogPrice[giveplayerid] = price;
OfferedHotdog[giveplayerid] = 1;
format(string, sizeof(string), "%s has offered you a hotdog for $%d (( /accepthotdog ))", GetPlayerNameEx(playerid), price);
SendClientMessage(giveplayerid, COLOR_YELLOW3, string);
format(string, sizeof(string), "You offered a hotdog to %s for $%d", GetPlayerNameEx(giveplayerid), price);
SendClientMessage(playerid, COLOR_SYSTEM, string);
}
else
{
SendClientMessage(playerid, COLOR_YELLOW3, "That player is not near you.");
return 1;
}
}
}
}