PDA

View Full Version : sell command


PaulDinam
02/10/2012, 10:29 AM
i need a simple sell command to other player ID, with price.

and then he will need to do /accept

nmader
02/10/2012, 10:56 AM
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?

PaulDinam
02/10/2012, 11:13 AM
like /sellhotdog
/accepthotdog
i need a simple one, so i could learn from it

nmader
02/10/2012, 11:33 AM
Alright... I will use ZCMD as it is much quicker and much easier for me to use.
enum PlayerStatistics //All the text in this pawn section goes towards the top of the script.
{
PendingHD,
OfferingHD,
};

new Player[MAX_PLAYERS][PlayerStatistics];
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;
}
}
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;
}

gtakillerIV
02/10/2012, 11:37 AM
And if you want it to be more better use if(IsPlayerInRangeOfPoint(targetid)).

nmader
02/10/2012, 11:46 AM
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. :)

PaulDinam
02/10/2012, 01:01 PM
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;
}
}
}
}