SA-MP Forums Archive
House system - 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: House system (/showthread.php?tid=633763)



House system - Loinal - 06.05.2017

Hello guys i converted sandra's prop system to house system but have some issues

PHP код:
CMD:addhouse(playerid, params[])
{
    new 
price2;
    if(
sscanf(params, "d", price2))
        return 
SendClientMessage(playerid, 0xFFFFFFAA, "Use: /addhouse [price]");
    if(
price2 < 10)
        return 
SendClientMessage(playerid, 0xFF0000FF,"Error: Price must be higher than 10"); //change this price if you want..
    // if(sell2 < 10) //i forgot they are just normal numbers. Strval is only used if you have a string, and you want to know it's value xd k wait a sec
    //     return SendClientMessage(playerid, 0xFF0000FF,"Error: Sell value must be higher than 10"); //change this value if you want..
       
static PropertyCount;
   
PropertyCount += 1;
    if(!
IsPlayerAdmin(playerid)) 
        return 
0;
    new 
Float:X, Float:Y, Float:Z;
    
GetPlayerPos(playerid, X, Y, Z);
    
//AddProperty(X,Y,Z, price2); //this calls a function that creates the pickup and assigns the variables.
    
HouseInfo[PropertyCount][HouseExists] = 1;
    
HouseInfo[PropertyCount][HouseX] = X;
    
HouseInfo[PropertyCount][HouseY] = Y;
    
HouseInfo[PropertyCount][HouseZ] = Z;
    
HouseInfo[PropertyCount][HouseValue] = price2;
    
HouseInfo[PropertyCount][HouseOwner] = -1;
    
HouseInfo[houseid][HouseIsBought] = 0;
    
PropertyPickup[PropertyCount] = CreatePickup(1272, 1, X, Y, Z);
    new 
entry[128], entry2[128];
    new 
File:hFile;
    
format(entry, 128, "AddProperty(%.2f, %.2f, %.2f, %d);", X, Y, Z, price2); //it only add's it to a file, and this has to be read.
    
format(entry2, 128, "\r\n%s",entry);
    
hFile = fopen("SavedProperties.txt", io_append);
    
fwrite(hFile, entry2);
    
fclose(hFile);
    return 
1;
} 
in game the pickup is showing but without info


Re: House system - Loinal - 07.05.2017

Any help?


Re: House system - ShihabSoft - 07.05.2017

You need to create a 3d text draw above the pickup with the info you want, then the info would be shown. Just creating a pickup won't show any text.


Re: House system - YouHack - 07.05.2017

Make it!
https://sampwiki.blast.hk/wiki/Create3DTextLabel


Re: House system - Loinal - 07.05.2017

Quote:
Originally Posted by YouHack
Посмотреть сообщение
Quote:
Originally Posted by ShihabSoft
Посмотреть сообщение
You need to create a 3d text draw above the pickup with the info you want, then the info would be shown. Just creating a pickup won't show any text.
Doesn't need because that

PHP код:
//OnPlayerPickUpPickUp
    
new houseid = -1; 
    new 
IDD = IsPlayerNearHouse(playerid);
    for(new 
idd; idd<MAX_HOUSES; idd++)
    {
        if(
HouseInfo[idd][HousePickup])
        {
            
houseid = idd;
            break;
        }
    }
    if(
houseid != -1)
    {
        new 
str[128];
        
format(str, 128, "~y~Price: ~w~$%d~n~~y~Owner: ~w~%s~n~~y~House ID: ~w~%d", HouseInfo[houseid][HouseValue], HouseInfo[houseid][HouseOwner], IDD);
        
GameTextForPlayer(playerid, str, 6000, 3);
        new 
ownerid = GetPlayerID(HouseInfo[IDD][HouseOwner]);
        if(
ownerid == playerid)
        {
              
SetPlayerHealth(ownerid,100.0);
            
SetPlayerArmour(ownerid,100.0);
        }
    } 
I think the problem that the command doesn't give id for the house how can i let it give id?


Re: House system - YouHack - 07.05.2017

You don't need ID to make it, also you're using GameTextForPlayer. house ID will appear where it's stored ( database )


Re: House system - Loinal - 07.05.2017

Its not saving at database its saving at a file on the filterscripts


Re: House system - ShihabSoft - 07.05.2017

So when the player enters the pickup area, it would popup a GameText.

Well then you've a simple logic error in it,

When creating new house /addhouse, you need to assign the CreatePickup returned value to HouseInfo array, just as shown in the code snippet below

Change from

PHP код:
    PropertyPickup[PropertyCount] = CreatePickup(1272, 1, X, Y, Z); 
TO

PHP код:
HouseInfo[idd][HousePickup] = CreatePickup(1272, 1, X, Y, Z); 
in your CMD:addhouse function.


Re: House system - YouHack - 07.05.2017

So I think you can retrieve the ID of it from the database in scriptfiles, easy! ( follow @ShihabSoft first, if it didn't work do what i told you )


Re: House system - Loinal - 07.05.2017

Quote:
Originally Posted by YouHack
Посмотреть сообщение
So I think you can retrieve the ID of it from the database in scriptfiles, easy! ( follow @ShihabSoft first, if it didn't work do what i told you )
Already its saving also his way is not working