12.07.2012, 14:19
So Guys I am going to teach you
How to make a simple Position Saveing System,its a bit easy thing tho.
but still many guys are not able to make it by themselfs and they start using a pre made Role Play Script
but its always better to use the one which is yours so no one can say you anything on it.
Well In This Tutorial i am not only going yo Teach you how to make a Simple Pos Saveing System but.......
a weapons and health saveing system too...............
SO LETS GET STARTED!
first the requirments are:
1>"You need to have basic knowledge of PWN"
2>"You should know how to make a simple Login/Register System or makeing enums"
So well i dont think so anyone likes to have more directory for just only getting the playerpos interior virtual world and weapons + health and armour so i am gona teach you how to add it to your server
1>go to your enum and add these
So it will look like this with a simple login register system.
2>add these lines in the callback where you are loading the player info's.
i dont need to teach it because i said you must have a bit knowledge of login/register system.
3>Now you need to save those values when a player disconnects an get where the player was and what he had so in call back OnPlayerDisconnect add this
4> now you need to save those values what you have got
so where you are saveing the values in a file add these lines too ,Dont ask me how to do that
5>now you need to give the player the things that he had on his last disconnect
but for more saftey and switching of the system and turing it on when you need so better make a int value for the server so that if the value is 1 it give player the things he had and makeing it 0 so it will not give player a thing you need to just only make a command to make the value keeping object to 1
so better go to OnGamemodeInt
add
6>So at Last you need to Give the Things he had + its the last step YAY!
add this code in OnPlayerConnect
SIMPLE THING! Dont it?
Well if you thing i didnt explained some thing Correctly post it below and i will fix it
If you still dont get it how to add this to your GM or want a trial Gm for it then try this.
https://sampforum.blast.hk/showthread.php?tid=358572
How to make a simple Position Saveing System,its a bit easy thing tho.
but still many guys are not able to make it by themselfs and they start using a pre made Role Play Script
but its always better to use the one which is yours so no one can say you anything on it.
Well In This Tutorial i am not only going yo Teach you how to make a Simple Pos Saveing System but.......
a weapons and health saveing system too...............
SO LETS GET STARTED!
first the requirments are:
1>"You need to have basic knowledge of PWN"
2>"You should know how to make a simple Login/Register System or makeing enums"
So well i dont think so anyone likes to have more directory for just only getting the playerpos interior virtual world and weapons + health and armour so i am gona teach you how to add it to your server
1>go to your enum and add these
pawn Code:
Float:pPosx,//to get player pos X(Float is there because player postions values are Float values)
Float:pPosy,// """" """" Y
Float:pPosz,//""""" " """" "" "" " " Z
pInt,//to get player Interior
pVw,//to get player virtual world
pW1,//to get player weapons
pWam1,
pW2,
pWam2,
pW3,
pWam3,
pW4,
pWam4,
pW5,
pWam5,
pW6,
pWam6,
pW7,
pWam7,
pW8,
pWam8,
Float:pHealth,//for getting player health
Float:pArmour//for getting player Armour
pawn Code:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pScores,
pRegisterd,
Float:pPosx,
Float:pPosy,
Float:pPosz,
pInt,
pVw,
pW1,
pWam1,
pW2,
pWam2,
pW3,
pWam3,
pW4,
pWam4,
pW5,
pWam5,
pW6,
pWam6,
pW7,
pWam7,
pW8,
pWam8,
Float:pHealth,
Float:pArmour
}
i dont need to teach it because i said you must have a bit knowledge of login/register system.
pawn Code:
INI_Float("X",PlayerInfo[playerid][pPosx]);//its INI_Float because you are loading a Float Value
INI_Float("Y",PlayerInfo[playerid][pPosy]);
INI_Float("Z",PlayerInfo[playerid][pPosz]);
INI_Int("Int",PlayerInfo[playerid][pInt]);//i ts INI_Int because you are loading a Integer Value
INI_Int("Vw",PlayerInfo[playerid][pVw]);
INI_Int("WEAPON 1",PlayerInfo[playerid][pW1]);
INI_Int("WEAPON AMMU 1",PlayerInfo[playerid][pWam1]);
INI_Int("WEAPON 2",PlayerInfo[playerid][pW2]);
INI_Int("WEAPON AMMU 2",PlayerInfo[playerid][pWam2]);
INI_Int("WEAPON 3",PlayerInfo[playerid][pW3]);
INI_Int("WEAPON AMMU 3",PlayerInfo[playerid][pWam3]);
INI_Int("WEAPON 4",PlayerInfo[playerid][pW4]);
INI_Int("WEAPON AMMU 4",PlayerInfo[playerid][pWam4]);
INI_Int("WEAPON 5",PlayerInfo[playerid][pW5]);
INI_Int("WEAPON AMMU 5",PlayerInfo[playerid][pWam5]);
INI_Int("WEAPON 6",PlayerInfo[playerid][pW6]);
INI_Int("WEAPON AMMU 6",PlayerInfo[playerid][pWam6]);
INI_Int("WEAPON 7",PlayerInfo[playerid][pW7]);
INI_Int("WEAPON AMMU 7",PlayerInfo[playerid][pWam7]);
INI_Int("WEAPON 8",PlayerInfo[playerid][pW8]);
INI_Int("WEAPON AMMU 8",PlayerInfo[playerid][pWam8]);
INI_Float("Health",PlayerInfo[playerid][pHealth]);
INI_Float("Armour",PlayerInfo[playerid][pArmour]);
pawn Code:
GetPlayerPos(playerid,PlayerInfo[playerid][pPosx],PlayerInfo[playerid][pPosy],PlayerInfo[playerid][pPosz]);
GetPlayerWeaponData(playerid,1,PlayerInfo[playerid][pW1],PlayerInfo[playerid][pWam1]);
GetPlayerWeaponData(playerid,2,PlayerInfo[playerid][pW2],PlayerInfo[playerid][pWam2]);
GetPlayerWeaponData(playerid,3,PlayerInfo[playerid][pW3],PlayerInfo[playerid][pWam3]);
GetPlayerWeaponData(playerid,4,PlayerInfo[playerid][pW4],PlayerInfo[playerid][pWam4]);
GetPlayerWeaponData(playerid,5,PlayerInfo[playerid][pW5],PlayerInfo[playerid][pWam5]);
GetPlayerWeaponData(playerid,6,PlayerInfo[playerid][pW6],PlayerInfo[playerid][pWam6]);
GetPlayerWeaponData(playerid,7,PlayerInfo[playerid][pW7],PlayerInfo[playerid][pWam7]);
GetPlayerWeaponData(playerid,8,PlayerInfo[playerid][pW8],PlayerInfo[playerid][pWam8]);
GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);
GetPlayerArmour(playerid,PlayerInfo[playerid][pArmour]);
// to get the player things when he is disconnecting
//these all are the functions of getting playerpos weapons and health + armour
so where you are saveing the values in a file add these lines too ,Dont ask me how to do that
pawn Code:
INI_WriteFloat(File,"X",PlayerInfo[playerid][pPosx]);
INI_WriteFloat(File,"Y",PlayerInfo[playerid][pPosy]);
INI_WriteFloat(File,"Z",PlayerInfo[playerid][pPosz]);
INI_WriteInt(File,"Int",GetPlayerInterior(playerid));
INI_WriteInt(File,"Vw",GetPlayerVirtualWorld(playerid));
INI_WriteInt(File,"WEAPON 1",PlayerInfo[playerid][pW1]);
INI_WriteInt(File,"WEAPON AMMU 1",PlayerInfo[playerid][pWam1]);
INI_WriteInt(File,"WEAPON 2",PlayerInfo[playerid][pW2]);
INI_WriteInt(File,"WEAPON AMMU 2",PlayerInfo[playerid][pWam2]);
INI_WriteInt(File,"WEAPON 3",PlayerInfo[playerid][pW3]);
INI_WriteInt(File,"WEAPON AMMU 3",PlayerInfo[playerid][pWam3]);
INI_WriteInt(File,"WEAPON 4",PlayerInfo[playerid][pW4]);
INI_WriteInt(File,"WEAPON AMMU 4",PlayerInfo[playerid][pWam4]);
INI_WriteInt(File,"WEAPON 5",PlayerInfo[playerid][pW5]);
INI_WriteInt(File,"WEAPON AMMU 5",PlayerInfo[playerid][pWam5]);
INI_WriteInt(File,"WEAPON 6",PlayerInfo[playerid][pW6]);
INI_WriteInt(File,"WEAPON AMMU 6",PlayerInfo[playerid][pWam6]);
INI_WriteInt(File,"WEAPON 7",PlayerInfo[playerid][pW7]);
INI_WriteInt(File,"WEAPON AMMU 7",PlayerInfo[playerid][pWam7]);
INI_WriteInt(File,"WEAPON 8",PlayerInfo[playerid][pW8]);
INI_WriteInt(File,"WEAPON AMMU 8",PlayerInfo[playerid][pWam8]);
INI_WriteFloat(File,"Health",PlayerInfo[playerid][pHealth]);
INI_WriteFloat(File,"Armour",PlayerInfo[playerid][pArmour]);
but for more saftey and switching of the system and turing it on when you need so better make a int value for the server so that if the value is 1 it give player the things he had and makeing it 0 so it will not give player a thing you need to just only make a command to make the value keeping object to 1
so better go to OnGamemodeInt
add
pawn Code:
new AutoSpawn =1;//if you need to turn off the system on needs make a command to make it 0 and 1 to turn it on
add this code in OnPlayerConnect
pawn Code:
if(AutoSpawn == 1)// only give things to player if AutoSpawn value is 1
{
if(PlayerInfo[playerid][pRegisterd] == 1){//checking is the player registerd if you made a value for player like this or remove this if function.
//well the below functions are to give the player the things he had
SetPlayerPos(playerid,PlayerInfo[playerid][pPosx],PlayerInfo[playerid][pPosy],PlayerInfo[playerid][pPosz]);
SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][pVw]);
SetPlayerInterior(playerid,PlayerInfo[playerid][pInt]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW1],PlayerInfo[playerid][pWam1]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW2],PlayerInfo[playerid][pWam2]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW3],PlayerInfo[playerid][pWam3]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW4],PlayerInfo[playerid][pWam4]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW5],PlayerInfo[playerid][pWam5]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW6],PlayerInfo[playerid][pWam6]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW7],PlayerInfo[playerid][pWam7]);
GivePlayerWeapon(playerid,PlayerInfo[playerid][pW8],PlayerInfo[playerid][pWam8]);
SetPlayerArmour(playerid,PlayerInfo[playerid][pArmour]);
SetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);}
else{
}
}
Well if you thing i didnt explained some thing Correctly post it below and i will fix it
If you still dont get it how to add this to your GM or want a trial Gm for it then try this.
https://sampforum.blast.hk/showthread.php?tid=358572