05.09.2009, 09:39
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
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:
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
Now useing CTRL+F you need to go to 'OnPlayerRegister' AND 'OnPlayerUpdate' and add these
CTRL+F to go to 'onplayerlogin' and add this
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:
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
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
Код:
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,
Код:
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;
Код:
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);
Код:
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 ); }
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; } }
**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