02.10.2012, 10:29
i need a simple sell command to other player ID, with price.
and then he will need to do /accept
and then he will need to do /accept
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;
}
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; } } } }