One of our brand new players, who just decided to move from SA:MP to VC:MP, asked me today about the known savedpositions.txt feature.
Wait, it's not known anymore, since 0.4 :)
(for the newbies: yeah, the feature was available in vc:mp 0.3)So, with
SLC's I/O Functionality (https://forum.vc-mp.org/?topic=6116.msg42113) documentation and functions, it was pretty easy to remake. (
Thanks!)
Decided to release it, maybe it will be helpful to other newbies too.
MUST create the savedpositions.txt first, before using the command;
if not, it will throw errors.But then, @DizzasTeR striked with his i/o knowledge and hit hard my code(before, I was reading and saving the whole file content in a variable, just to add a new line at the end)So now, we have a way to add a new line without rewritting the text from the file!(didn't know, didn't google c:)AND ALSO, NO NEED TO CREATE THE FILE BY YOURSELF ANYMORE! Go ahead and test it!
onPlayerCommand( player, cmd, text )if( cmd == "s" || cmd == "save" )
{
local veh = player.Vehicle;
local newline;
if( !veh ) {
// the below script will check all player's weapons and save the first 3 the script founds
local wep = array(3);
wep[0] = { ID = 0, Ammo = 0 };
wep[1] = { ID = 0, Ammo = 0 };
wep[2] = { ID = 0, Ammo = 0 };
local weps = 0;
for( local i = 0; i < 9; i++ ) {
if( player.GetWeaponAtSlot(i) != 0 && weps < 3 ) {
wep[weps] = {
ID = i,
Ammo = player.GetAmmoAtSlot(i)
};
weps++;
if( weps == 3 ) break;
}
}
// format is AddClass( class, color, skin, position, angle, weapon1, ammo1 ,weapon2, ammo2, weapon3, ammo3 );
newline = "AddClass( " + player.Class + ", RGB(" + player.Colour.r + ", " + player.Colour.g + ", " + player.Colour.b + "), "
+ player.Skin + ", Vector" + player.Pos + ", " + player.Angle + ", "
+ wep[0].ID + ", " + wep[0].Ammo + ", " + wep[1].ID + ", " + wep[1].Ammo + ", " + wep[2].ID + ", " + wep[2].Ammo + " ); \n";
}
else {
// format is CreateVehicle( model, world, pos, angle, col1, col2 )
newline = "CreateVehicle( " + veh.Model + ", " + veh.World + ", Vector" + veh.Pos + ", " + veh.Rotation.z + ", " + veh.Colour1 + ", " + veh.Colour2 + " ); \n";
}
local f = file("savedpositions.txt","a+");
foreach (c in newline)
f.writen(c, 'b');
f.close();
}
(https://i.imgur.com/pMX2tgy.png)
PS: For the some of you who are using the older version, better upgrade to this one.
Huge thanks from me to Sebastian for releasing this, switching from samp to vcmp i really missed this feature. Love the vc:mp community so far, really helpful staff.
@DizzasTeR shown me an even better way to do it, so I will try to update the code later today when I come back from work.
Be eyes-open!
Done. First post updated.
@Genon_May please use this updated command instead of the old one. :)