/house selltomarket "confirm" how to?
#1

Код:
if(strcmp(option, "selltomarket", true) == 0)
	{
		for(new i; i < MAX_HOUSES; i++)
	   	{
		   	if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[i][ExteriorPos][0], HouseInfo[i][ExteriorPos][1], HouseInfo[i][ExteriorPos][2]))
		   	{
		   		if(HouseInfo[i][server_ID] == PlayerInfo[playerid][HouseID])
		   		{
					new houseprice = HouseInfo[i][Price]*50/100;
					format(str, sizeof(str), "You've sold your house for $%d!", houseprice);
					SendClientMessage(playerid, COLOR_GREY, str);
					DestroyDynamicPickup(HouseInfo[i][Pickup]);
					DestroyDynamic3DTextLabel(HouseInfo[i][Label]);
					HouseInfo[i][Pickup] = CreateDynamicPickup(1273, 23, HouseInfo[i][ExteriorPos][0], HouseInfo[i][ExteriorPos][1], HouseInfo[i][ExteriorPos][2], HouseInfo[i][ExteriorWorld]);
					format(housestring, sizeof(housestring), "{70ff83}This house is for sell!\nPrice: %d\nType /buyhouse to buy it\nType /enter to go inside", HouseInfo[i][Price]);
					HouseInfo[i][Label] = CreateDynamic3DTextLabel(housestring , COLOR_ORANGE, HouseInfo[i][ExteriorPos][0], HouseInfo[i][ExteriorPos][1], HouseInfo[i][ExteriorPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0);
					HouseInfo[i][ForSell] = 1;
					HouseInfo[i][Locked] = 0;
					GiveMoney(playerid, houseprice);
					return 1;
				}

				return 1;
			}
		}
		return 1;
	}
How can I do that player has to write /house selltomarket confirm from this?
Reply
#2

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

new bool:g_HouseSale[MAX_PLAYERS];

CMD:house(playerid, params[])
{
    new option[24];
    
    if(sscanf(params, "s[24]", option)) 
        return SendClientMessage(playerid, -1, "USAGE: /house [selltomarket | selltomarket confirm]");
    
    if(!strcmp(option, "selltomarket confirm", true))
    {
        if(!g_HouseSale[playerid])
            return SendClientMessage(playerid, -1, "Use /house selltomarket");


        g_HouseSale[playerid] = false;
        SendClientMessage(playerid, -1, "House sold.");
        // User confirmed the sale
        return 1;
    }

    if(!strcmp(option, "selltomarket", true))
    {
        SendClientMessage(playerid, -1, "Use /house selltomarket confirm");
        g_HouseSale[playerid] = true;
        return 1;
    }
    return 1;
}
Reply
#3

nope it didnt work. I dont need a command for it, I tried using it in my cmd, i showed u my code i just need when player types "house selltomarket confirm' to execute the cmd
Reply
#4

PHP код:
new sellOwnedHouseID[MAX_PLAYERS]={-1,...};
findOwnedHouse(playerid){
    for(new 
iMAX_HOUSESi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid2.0HouseInfo[i][ExteriorPos][0], HouseInfo[i][ExteriorPos][1], HouseInfo[i][ExteriorPos][2]) && 
            
HouseInfo[i][server_ID] == PlayerInfo[playerid][HouseID])
            return 
i;
    }
    return -
1;
}
updateHouseInfo(i){
    
DestroyDynamicPickup(HouseInfo[i][Pickup]);
    
DestroyDynamic3DTextLabel(HouseInfo[i][Label]);
    new 
s[100];
    
HouseInfo[i][Pickup] = CreateDynamicPickup(127323HouseInfo[i][ExteriorPos][0], HouseInfo[i][ExteriorPos][1], HouseInfo[i][ExteriorPos][2], HouseInfo[i][ExteriorWorld]);
    
format(s100"{70ff83}This house is for sell!\nPrice: %d\nType /buyhouse to buy it\nType /enter to go inside"HouseInfo[i][Price]);
    
HouseInfo[i][Label] = CreateDynamic3DTextLabel(COLOR_ORANGEHouseInfo[i][ExteriorPos][0], HouseInfo[i][ExteriorPos][1], HouseInfo[i][ExteriorPos][2],30.0
    
INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -17.0);
}
CMD:house(pid,p[]){
    new 
opt1[32],
        
opt2[32],
        
s[100],
        
i;
    if(
sscanf(params,"s[32]s[32]",opt1,opt2))return SendClientMessage(pid,-1,"/house [selltomarket / selltomarket confirm]");
    if(!
strcmp(opt1,"selltomarket")){
        if(
strlen(opt2) && !strcmp(opt2,"confirm")){
            if((
i=sellOwnedHouseID[pid])==-1)return SendClientMessage(pid,-1,"you haven't seleted any house to sell!");
            new 
houseprice floatround(HouseInfo[i][Price]*0.5);
            
updateHouseInfo(i);
            
HouseInfo[i][ForSell] = 1;
            
HouseInfo[i][Locked] = 0;
            
GiveMoney(playeridhouseprice);
            
sellOwnedHouseID[pid]=-1;
            
format(s100"You've sold your house for $%d!"houseprice);
            
SendClientMessage(playeridCOLOR_GREYstr);
        }else{
            if(
sellOwnedHouseID[pid]!=-1)return SendClientMessage(pid,-1,"you are already selling some house type (/house selltomarket confirm)!");
            if((
i=findOwnedHouse(pid))==-1)return SendClientMessage(pid,-1,"you arent near to any of your houses!");
            
sellOwnedHouseID[pid]=i;
            
SendClientMessage(pid,-1,"you are selling your house, type (/house selltomarket confirm)");
        }
    }
    return 
1;

Reply
#5

That should work but it looks ugly and has no time constraints of validity.

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

new bool:g_HouseSale[MAX_PLAYERS];

CMD:house(playerid, params[])
{
    new option[24];
    
    if(sscanf(params, "s[24]", option)) 
        return SendClientMessage(playerid, -1, "USAGE: /house [selltomarket | selltomarket confirm]");
    
    if(!strcmp(option, "selltomarket confirm", true))
    {
        if(!g_HouseSale[playerid])
            return SendClientMessage(playerid, -1, "Use /house selltomarket");


        g_HouseSale[playerid] = false;
        SendClientMessage(playerid, -1, "House sold.");
        // User confirmed the sale
        return 1;
    }

    if(!strcmp(option, "selltomarket", true))
    {
        SendClientMessage(playerid, -1, "Use /house selltomarket confirm");
        g_HouseSale[playerid] = true;
        return 1;
    }
    return 1;
}
Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define         HOUSE_SELL_TIMELIMIT        60

new g_HouseSale[MAX_PLAYERS];

CMD:house(playerid, params[])
{
	if(!IsNull(params))
	{
		if(gettime() - g_HouseSale[playerid] < HOUSE_SELL_TIMELIMIT &&
			!strcmp(option, "selltomarket confirm", true))
		{
			if(!g_HouseSale[playerid]) SendClientMessage(playerid, -1, "Use /house selltomarket");
			else
			{
				g_HouseSale[playerid] = 0;
				SendClientMessage(playerid, -1, "House sold.");
			}
		}
		else if(!strcmp(option, "selltomarket", true))
		{
			SendClientMessage(playerid, -1, "Use /house selltomarket confirm");
			g_HouseSale[playerid] = gettime();
		}
	}
	else SendClientMessage(playerid, -1, "USAGE: /house [selltomarket | selltomarket confirm]");
 	return 1;
}
Reply
#6

That's a very good usage of gettime()

(You still included uselessly sscanf ^^)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)