House system
#1

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

PHP код:
CMD:addhouse(playeridparams[])
{
    new 
price2;
    if(
sscanf(params"d"price2))
        return 
SendClientMessage(playerid0xFFFFFFAA"Use: /addhouse [price]");
    if(
price2 10)
        return 
SendClientMessage(playerid0xFF0000FF,"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:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    
//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(12721XYZ);
    new 
entry[128], entry2[128];
    new 
File:hFile;
    
format(entry128"AddProperty(%.2f, %.2f, %.2f, %d);"XYZprice2); //it only add's it to a file, and this has to be read.
    
format(entry2128"\r\n%s",entry);
    
hFile fopen("SavedProperties.txt"io_append);
    
fwrite(hFileentry2);
    
fclose(hFile);
    return 
1;

in game the pickup is showing but without info
Reply
#2

Any help?
Reply
#3

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.
Reply
#4

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

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 
iddidd<MAX_HOUSESidd++)
    {
        if(
HouseInfo[idd][HousePickup])
        {
            
houseid idd;
            break;
        }
    }
    if(
houseid != -1)
    {
        new 
str[128];
        
format(str128"~y~Price: ~w~$%d~n~~y~Owner: ~w~%s~n~~y~House ID: ~w~%d"HouseInfo[houseid][HouseValue], HouseInfo[houseid][HouseOwner], IDD);
        
GameTextForPlayer(playeridstr60003);
        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?
Reply
#6

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

Its not saving at database its saving at a file on the filterscripts
Reply
#8

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(12721XYZ); 
TO

PHP код:
HouseInfo[idd][HousePickup] = CreatePickup(12721XYZ); 
in your CMD:addhouse function.
Reply
#9

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 )
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)