SA-MP Forums Archive
How would i do this - 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: How would i do this (/showthread.php?tid=340429)



How would i do this - Scripter12345 - 07.05.2012

So i am saving all my data .... but the problem is in my scriptfiles / users


It shows like this


Код:
Price = 500
Owned = 0
VirtualWorld = 0
XPos = 1133.019165
YPos = -1487.999877
ZPos = 22.769031
Owner = -----
[data]
Password = 41943361
Cash = 0
Admin = 0
Kills = 0
Deaths = 0
PosX = 1129.353393
PosY = -1487.964721
PosZ = 22.769031
AdminLevel = 5
AdminName = ------
AdminDuty = 0
AdminSkin = 31
OriginalSkin = 0
OriginalName = -----
How can i make it so the house stuff ( Which is above the tag data ) is below every thing else


Thank You


Please Help Me Please


Re: How would i do this - Jonny5 - 07.05.2012

save it last instead of first?
Add the SetTag("House");


you have got to be kidding me here.

and without seeing your code we cant help.


Re: How would i do this - Scripter12345 - 07.05.2012

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
save it last instead of first?
Add the SetTag("House");


you have got to be kidding me here.

and without seeing your code we cant help.
What code do you need


Re: How would i do this - Jonny5 - 07.05.2012

the code that saves the user file would seam logical to me here.


Re: How would i do this - Scripter12345 - 07.05.2012

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
the code that saves the user file would seam logical to me here.
pawn Код:
CMD:createhouse(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You aren't an admin!");//Check if the player is currently rcon logged in.
    new HousePrice,id = HouseCount;//Creating the house price for the selected value in the command, and the last house id created.
    if(sscanf(params,"i",HousePrice)) return SendClientMessage(playerid,-1,"USAGE: /createhouse <price>");//Checking if the player uses the correct syntax. The parameter "i" in sscanf means integer, also could be used as "d".
    new Float:x,Float:y,Float:z;//Creating the floats, to store the player's position.
    GetPlayerPos(playerid,x,y,z);//Getting the player's position and storing it
    HInfo[id][Price] = HousePrice;//Setting the house price to the selected one.
    HInfo[id][Owned] = 0;//Setting the house id owned = 0
    HInfo[id][XPos] = x;//Storing the XPos value to the player's x.
    HInfo[id][YPos] = y;//Storing the YPos value to the player's y.
    HInfo[id][ZPos] = z;//Storing the ZPos value to the player's z.
    HInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
    format(HInfo[id][Owner],24,"Nonusablenameforthishouse");//Formating the "Owner" house id value to "Nonusablenameforthishouse".
    SendClientMessage(playerid,-1,"House created");
    HouseEnter[id]  = CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));//Creating the checkpoint and storing it in the HouseEnter value.
    HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));//Creating the house exit checkpoint and storing it in the HouseExit value.
    new INI:File = INI_Open(UserPath(playerid));
    INI_WriteInt(File,"Price",HousePrice);//Writing in the place "Price" the inputted "Price" value.
    INI_WriteInt(File,"Owned",0);//Setting to "Owned" = 0 in the ini file.
    INI_WriteInt(File,"VirtualWorld",GetPlayerVirtualWorld(playerid));//Writing "VirtualWorld" = GetPlayerVirtualWorld(..);
    INI_WriteFloat(File,"XPos",x);//Writing the players pos for the check point position.
    INI_WriteFloat(File,"YPos",y);//Self explanatory.
    INI_WriteFloat(File,"ZPos",z);//Self explanatory.
    INI_WriteString(File,"Owner","Nonusablenameforthishouse");//Writing a string in "Owned" to "Nonusablenameforthishouse"
    INI_Close(File);//Closing the file with SII.
    HouseCount++;
    return 1;
}

Thank You


Please Help Me Please


Re: How would i do this - Jonny5 - 07.05.2012

pawn Код:
CMD:createhouse(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You aren't an admin!");//Check if the player is currently rcon logged in.
    new HousePrice,id = HouseCount;//Creating the house price for the selected value in the command, and the last house id created.
    if(sscanf(params,"i",HousePrice)) return SendClientMessage(playerid,-1,"USAGE: /createhouse <price>");//Checking if the player uses the correct syntax. The parameter "i" in sscanf means integer, also could be used as "d".
    new Float:x,Float:y,Float:z;//Creating the floats, to store the player's position.
    GetPlayerPos(playerid,x,y,z);//Getting the player's position and storing it
    HInfo[id][Price] = HousePrice;//Setting the house price to the selected one.
    HInfo[id][Owned] = 0;//Setting the house id owned = 0
    HInfo[id][XPos] = x;//Storing the XPos value to the player's x.
    HInfo[id][YPos] = y;//Storing the YPos value to the player's y.
    HInfo[id][ZPos] = z;//Storing the ZPos value to the player's z.
    HInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
    format(HInfo[id][Owner],24,"Nonusablenameforthishouse");//Formating the "Owner" house id value to "Nonusablenameforthishouse".
    SendClientMessage(playerid,-1,"House created");
    HouseEnter[id]  = CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));//Creating the checkpoint and storing it in the HouseEnter value.
    HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));//Creating the house exit checkpoint and storing it in the HouseExit value.
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "House");
    INI_WriteInt(File,"Price",HousePrice);//Writing in the place "Price" the inputted "Price" value.
    INI_WriteInt(File,"Owned",0);//Setting to "Owned" = 0 in the ini file.
    INI_WriteInt(File,"VirtualWorld",GetPlayerVirtualWorld(playerid));//Writing "VirtualWorld" = GetPlayerVirtualWorld(..);
    INI_WriteFloat(File,"XPos",x);//Writing the players pos for the check point position.
    INI_WriteFloat(File,"YPos",y);//Self explanatory.
    INI_WriteFloat(File,"ZPos",z);//Self explanatory.
    INI_WriteString(File,"Owner","Nonusablenameforthishouse");//Writing a string in "Owned" to "Nonusablenameforthishouse"
    INI_Close(File);//Closing the file with SII.
    HouseCount++;
    return 1;
}
im not sure why it matters where the data is in the ini file but there ya go