[Tutorial] [TUT] How to make Dynamic housing for your server.
#1

Introduction
This is a tutorial on how to make /buyhouse [entrance/car/level] for your server. The server i worked with (LSR) asked me to make it just like SZR's system so i tried and i think i made it a little differently to how SZR make it as i suspect SZR used a better system then what i used (most scripters will realise what i mean when you read this tutorial). So, i made this for LSR but now i realise that they carelessly let the script get released i think im going to just make tutorial on how to add the house system to your own script. On this tutorial i will be making it on the register system that GodFather scripts use, but you should change parts of it to use for your own register system, So enjoy.

Chapter 1: Adding the 'PlayerInfo'
Ok, the way ive done it is adding the system into the Player's scriptfile and i do not think this is the best way to do it, in fact its probaly the work way, but im not a great scripter, so this is all i can do.

Ok, instead of doing each part one by one, we will do it all at once, first of all pres CTRL+F and type in

Код:
enum pInfo
Now you should see a lot of code such as: pAdmin,pLevel e.t.c. In this list you need to add all of these:

Код:
	Float:pHouseX,
	Float:pHouseY,
	Float:pHouseZ,
	pHouseVW,
 	Float:pHouseIntX,
	Float:pHouseIntY,
	Float:pHouseIntZ,
	pHouseInt,
	Float:pHouseCarX,
	Float:pHouseCarY,
	Float:pHouseCarZ,
	Float:pHouseCarAngle,
	pHouseCarId,
	pHouseCarLocked, // 0 unlocked, 1 locked
	pHouseCarColorChosen,
	pHouseCarColor1,
	pHouseCarColor2,
	pHouseLevel,
	pHouseSpawn,
 	pEnterHouse,
	pGotEntrance,
	pGotCar,
	pMakingHouse,
	pOwnsHouse,
Now if you compile i do not think it will work but dont worry, its not meant to. now use CTRL+f to look for onplayerconnect and you need to add this to the list that already there

Код:
	PlayerInfo[playerid][pHouseX] = 0;
	PlayerInfo[playerid][pHouseY] = 0;
	PlayerInfo[playerid][pHouseZ] = 0;
	PlayerInfo[playerid][pHouseVW] = 0;
	PlayerInfo[playerid][pHouseIntX] = 0;
	PlayerInfo[playerid][pHouseIntY] = 0;
	PlayerInfo[playerid][pHouseIntZ] = 0;
	PlayerInfo[playerid][pHouseInt] = 0;
	PlayerInfo[playerid][pHouseCarX] = 0;
	PlayerInfo[playerid][pHouseCarY] = 0;
	PlayerInfo[playerid][pHouseCarZ] = 0;
	PlayerInfo[playerid][pHouseCarAngle] = 0;
	PlayerInfo[playerid][pHouseCarId] = 0;
	PlayerInfo[playerid][pHouseCarLocked] = 0;
	PlayerInfo[playerid][pHouseCarColorChosen] = 0;
	PlayerInfo[playerid][pHouseCarColor1] = 0;
	PlayerInfo[playerid][pHouseCarColor2] = 0;
	PlayerInfo[playerid][pHouseLevel] = 0;
	PlayerInfo[playerid][pHouseSpawn] = 0;
 	PlayerInfo[playerid][pGotEntrance] = 0;
	PlayerInfo[playerid][pGotCar] = 0;
	PlayerInfo[playerid][pOwnsHouse] = 0;
	PlayerInfo[playerid][pEnterHouse] = 0;
	PlayerInfo[playerid][pMakingHouse] = 0;
Now useing CTRL+F you need to go to 'OnPlayerRegister' AND 'OnPlayerUpdate' and add these

Код:
				format(var, 32, "pHouseX=%.1f\n",PlayerInfo[playerid][pHouseX]);fwrite(hFile, var);
				format(var, 32, "pHouseY=%.1f\n",PlayerInfo[playerid][pHouseY]);fwrite(hFile, var);
				format(var, 32, "pHouseZ=%.1f\n",PlayerInfo[playerid][pHouseZ]);fwrite(hFile, var);
				format(var, 32, "pHouseVW=%d\n",PlayerInfo[playerid][pHouseVW]);fwrite(hFile, var);
  			format(var, 32, "pHouseIntX=%.1f\n",PlayerInfo[playerid][pHouseIntX]);fwrite(hFile, var);
				format(var, 32, "pHouseIntY=%.1f\n",PlayerInfo[playerid][pHouseIntY]);fwrite(hFile, var);
				format(var, 32, "pHouseIntZ=%.1f\n",PlayerInfo[playerid][pHouseIntZ]);fwrite(hFile, var);
        format(var, 32, "pHouseInt=%d\n",PlayerInfo[playerid][pHouseInt]);fwrite(hFile, var);
        format(var, 32, "pHouseCarX=%.1f\n",PlayerInfo[playerid][pHouseCarX]);fwrite(hFile, var);
        format(var, 32, "pHouseCarY=%.1f\n",PlayerInfo[playerid][pHouseCarY]);fwrite(hFile, var);
        format(var, 32, "pHouseCarZ=%.1f\n",PlayerInfo[playerid][pHouseCarZ]);fwrite(hFile, var);
        format(var, 32, "pHouseCarAngle=%.1f\n",PlayerInfo[playerid][pHouseCarAngle]);fwrite(hFile, var);
        format(var, 32, "pHouseCarId=%d\n",PlayerInfo[playerid][pHouseCarId]);fwrite(hFile, var);
        format(var, 32, "pHouseCarLocked=%d\n",PlayerInfo[playerid][pHouseCarLocked]);fwrite(hFile, var);
        format(var, 32, "pHouseCarColorChosen=%d\n",PlayerInfo[playerid][pHouseCarColorChosen]);fwrite(hFile, var);
				format(var, 32, "pHouseCarColor1=%d\n",PlayerInfo[playerid][pHouseCarColor1]);fwrite(hFile, var);
        format(var, 32, "pHouseCarColor2=%d\n",PlayerInfo[playerid][pHouseCarColor2]);fwrite(hFile, var);
        format(var, 32, "pHouseLevel=%d\n",PlayerInfo[playerid][pHouseLevel]);fwrite(hFile, var);
        format(var, 32, "pHouseSpawn=%d\n",PlayerInfo[playerid][pHouseSpawn]);fwrite(hFile, var);
        format(var, 32, "EnterHouse=%d\n",PlayerInfo[playerid][pEnterHouse]);fwrite(hFile, var);
				format(var, 32, "GotEntrance=%d\n",PlayerInfo[playerid][pGotEntrance]);fwrite(hFile, var);
				format(var, 32, "MakingHouse=%d\n",PlayerInfo[playerid][pMakingHouse]);fwrite(hFile, var);
				format(var, 32, "OwnsHouse=%d\n",PlayerInfo[playerid][pOwnsHouse]);fwrite(hFile, var);
				format(var, 32, "GotCar=%d\n",PlayerInfo[playerid][pGotCar]);fwrite(hFile, var);
CTRL+F to go to 'onplayerlogin' and add this

Код:
 if( strcmp( key , "pHouseX" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseX] = strval( val ); }
		     	if( strcmp( key , "pHouseY" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseY] = strval( val ); }
		     	if( strcmp( key , "pHouseZ" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseZ] = strval( val ); }
		     	if( strcmp( key , "pHouseVW" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseVW] = strval( val ); }
      		if( strcmp( key , "pHouseIntX" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseIntX] = strval( val ); }
		     	if( strcmp( key , "pHouseIntY" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseIntY] = strval( val ); }
		     	if( strcmp( key , "pHouseIntZ" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseIntZ] = strval( val ); }
		     	if( strcmp( key , "pHouseInt" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseInt] = strval( val ); }
		     	if( strcmp( key , "pHouseCarX" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarX] = strval( val ); }
		     	if( strcmp( key , "pHouseCarY" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarY] = strval( val ); }
		     	if( strcmp( key , "pHouseCarZ" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarZ] = strval( val ); }
		     	if( strcmp( key , "pHouseCarAngle" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarAngle] = strval( val ); }
		     	if( strcmp( key , "pHouseCarId" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarId] = strval( val ); }
		     	if( strcmp( key , "pHouseCarLocked" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarLocked] = strval( val ); }
		     	if( strcmp( key , "pHouseCarColorChosen" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarColorChosen] = strval( val ); }
		     	if( strcmp( key , "pHouseCarColor1" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarColor1] = strval( val ); }
		     	if( strcmp( key , "pHouseCarColor2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseCarColor2] = strval( val ); }
		     	if( strcmp( key , "pHouseLeveL" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseLevel] = strval( val ); }
          if( strcmp( key , "pHouseSpawn" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHouseSpawn] = strval( val ); }
 			    if( strcmp( key , "EnterHouse" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pEnterHouse] = strval( val ); }
			    if( strcmp( key , "GotEntrance" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGotEntrance] = strval( val ); }
			    if( strcmp( key , "MakingHouse" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMakingHouse] = strval( val ); }
			    if( strcmp( key , "OwnsHouse" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pOwnsHouse] = strval( val ); }
			    if( strcmp( key , "GotCar" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGotCar] = strval( val ); }
Ok, now that is done, i think it should compile now unless i made a mistake or you made a mistake, Well once this compiles we can get onto the next Chapter

Chapter 2: Adding the 'Commands'
I do not want to do any more of this so im just going to paste all the commands into a Pastebin and you can all just copy and paste it into your Script (also ill have variables for the commands in pastebin if there is any needed). So go on this link, put in your script and if it does not compile after yuo entered the commands, do each command one by one and then eventually u will find out wich one is broken and u can ask in a reply...

http://pastebin.com/f121a987e

EDIT:
I forot to mention the LoadHouseCars callback that i did, this is vital.. so just add this Public and the callbacks on the script

http://pastebin.com/f478f95e7

THis goes underneath /accept command, variables in Pastebin:

Код:
			else if(strcmp(x_job,"invitation",true) == 0)
			{
	      if(InvitedToHouse[playerid] == 1)
				{
					new HouseOwner[MAX_PLAYER_NAME];
	  				GetPlayerName(playerid, HouseOwner, sizeof(HouseOwner));
	  				new invitedguy[MAX_PLAYER_NAME];
	  				GetPlayerName(giveplayerid, invitedguy, sizeof(invitedguy));
					format(string, sizeof(string), "* You have accepted your friends invitation.");
					SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
					new houseowner = InvitedToHouseOwnerId[playerid];
	        new Float:housex = PlayerInfo[houseowner][pHouseX];
	      	new Float:housey = PlayerInfo[houseowner][pHouseY];
	      	 	new Float:housez = PlayerInfo[houseowner][pHouseZ];
					format(string, sizeof(string), "* Your friend has accepted your house invitation.");
					SendClientMessage(houseowner, COLOR_LIGHTBLUE, string);
					SetPlayerCheckpoint(playerid,housex,housey,housez,2.5);
					return 1;
				}
				else
				{
					SendClientMessage(playerid,COLOR_GREY, "	No-one offered you a House Invitation !");
					return 1;
				}
			}
So thats pretty much it, if it dont work cos i missed sumin, just say in reply either i can help you or a pro can help you but have fun with it

**p.s i give some credit to Aaron from LSR for added all the cars is /housecarupgrade cos i coulnt be assed and for making it look like SZR's system (the text and stuff)**


EDIT:

Here is the /enter and /exit and Thankyou to 'SergiKirov' on the forums for giving me the script so i can give you all the /enter and /exit codes - i am going to just give you the whole enter and exit then you can extract the bit you need from it if you liek

http://pastebin.com/fe49683b


Reply
#2

Nice tutorial but downloading a house system is much faster
Reply
#3

Quote:
Originally Posted by Kurence
Nice tutorial but downloading a house system is much faster
ye i know but doing this means people can put this straight into script and i made this and i dont want it to go to waste
Reply
#4

Good one, keep it up .

+1
Reply
#5

if someone could try it out and tell me if they manage to get this working that would be good so i know if i gotta make a proper tutorial that makes sense
Reply
#6

Nice tutorial good job.
Reply
#7

lol you got this from LSR RolePlay script their the only script that has their dynamic housing like that...

_

Anyway good job on the tut tho
Reply
#8

Quote:
Originally Posted by [vRP
LeeWasabi ]
lol you got this from LSR RolePlay script their the only script that has their dynamic housing like that...

_

Anyway good job on the tut tho
SZr was the first creator of that script, LSR remade it and released it.
Reply
#9

Код:
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(21820) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(21846) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(21872) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(21898) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(21924) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(21950) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(21976) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(22002) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(22028) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(22054) : error 017: undefined symbol "LoadHouseCars"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(22382) : error 017: undefined symbol "MAX_POINTS"
D:\DOCUME~1\vador\Desktop\src\MWRP14.pwn(22399) : error 017: undefined symbol "MAX_POINTS"
got that good tut on other hand
Reply
#10

Quote:
Originally Posted by NEW_IE
Посмотреть сообщение
lol you got this from LSR RolePlay script their the only script that has their dynamic housing like that...

_

Anyway good job on the tut tho
woooahhh, i made this... ( I am mowgli btw on my new account... i cant remember pass for " mowgli " and cba to send for password on email)..

look in LSR credits it should say "dynamic housing by Mowgli" or maybe even Darren Reeder...

---

The owner of LSR asked me to create the SZR housing system so i did... My credits are all over the LSR script..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)