Buy/Sell property
#1

Im trying to make buy/sell faction/house system.For now i have made the /buy function but when i restart the server other players can buy the house or faction.

Код:
new cityhallpropertyoffice;
cityhallpropertyoffice = CreatePickup(1239, 2, 362.8641, 155.2817, 1024.7963, -1);

public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(pickupid == cityhallpropertyoffice)
	{
	    ShowPlayerDialog(playerid, 6, DIALOG_STYLE_LIST, "Property Office", "Faction\nHouses", "Select","Close");
	}
	if(pickupid == accjob)

	if(dialogid == 6)
	{
	    if(response)
	    {
	        if(listitem == 0)
	        {
	            ShowPlayerDialog(playerid, 7, DIALOG_STYLE_LIST, "Bussines","Building faction","Buy","Close");
			}
			if(listitem == 1)
			{
			    ShowPlayerDialog(playerid, 8, DIALOG_STYLE_LIST, "Houses", "House 1\nHouse 2\nHouse 3", "Buy","Close");
			}
		}
	}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 7)
	{
		if(response)
		{
			if(listitem == 0)
			{
				new INI:File = INI_Open(UserPath(playerid));
				new name[MAX_PLAYER_NAME];
		 		GetPlayerName(playerid, name, sizeof(name));
  				INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
   				if(Chars[playerid][pBusiness] == 0)
				{
			    	INI_SetTag(File,"data");
			    	INI_WriteInt(File,"Business",Chars[playerid][pBusiness] = 1);
			    	INI_Close(File);
					Bfaction[playerid][Owner] = 1;
					pInfo[playerid] [pBuilding] = 1;

				}
				else
				{
					if(pInfo[playerid][pBuilding] == 1)
					{
						SendClientMessage(playerid,COLOR_RED,"This faction is allready bought from someone else");
					}
				}
			}
		}
	}
	if(dialogid == 8)
	{
	    if(response)
	    {
	        if(listitem == 0)
	        {
	            SendClientMessage(playerid,COLOR_RED, "There is no house for sale");
			}
 	        if(listitem == 1)
	        {
	            SendClientMessage(playerid,COLOR_RED, "There is no house for sale");
			}
 	        if(listitem == 2)
	        {
	            SendClientMessage(playerid,COLOR_RED, "There is no house for sale");
			}
		}
	}
    return 1;
}
That is what i have done for now.

(P.S. I still suck at scripting so.. i will need your help guys )
Reply
#2

Can anyone help ... :/
Reply
#3

Haha why do you have a dialog code in your pickups callback?
Reply
#4

this will get you on the right track
PHP код:

//Top of script
new cityhallpropertyoffice;
cityhallpropertyoffice CreatePickup(12392362.8641155.28171024.7963, -1);
#define DialogCityHallOffice 6
public OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == cityhallpropertyoffice)
    {
        
ShowPlayerDialog(playeridDialogCityHallOfficeDIALOG_STYLE_LIST"Property Office""Faction\nHouses""Select","Close");
    }
    
//if(pickupid == accjob){}
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DialogCityHallOffice)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
ShowPlayerDialog(playerid7DIALOG_STYLE_LIST"Bussines","Building faction","Buy","Close");
            }
            if(
listitem == 1)
            {
                
ShowPlayerDialog(playerid8DIALOG_STYLE_LIST"Houses""House 1\nHouse 2\nHouse 3""Buy","Close");
            }
        }
    }
    if(
dialogid == 7)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                new 
INI:File INI_Open(UserPath(playerid));
                new 
name[MAX_PLAYER_NAME];
                 
GetPlayerName(playeridnamesizeof(name));
                  
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                   if(
Chars[playerid][pBusiness] == 0)
                {
                    
INI_SetTag(File,"data");
                    
INI_WriteInt(File,"Business",Chars[playerid][pBusiness] = 1);
                    
INI_Close(File);
                    
Bfaction[playerid][Owner] = 1;
                    
pInfo[playerid] [pBuilding] = 1;
                }
                else
                {
                    if(
pInfo[playerid][pBuilding] == 1)
                    {
                        
SendClientMessage(playerid,COLOR_RED,"This faction is allready bought from someone else");
                    }
                }
            }
        }
    }
    if(
dialogid == 8)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
SendClientMessage(playerid,COLOR_RED"There is no house for sale");
            }
             if(
listitem == 1)
            {
                
SendClientMessage(playerid,COLOR_RED"There is no house for sale");
            }
             if(
listitem == 2)
            {
                
SendClientMessage(playerid,COLOR_RED"There is no house for sale");
            }
        }
    }
    return 
1;

Reply
#5

tnx and about the call back i don`t know
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)