Vice City: Multiplayer

VC:MP Discussion => General Discussion => Topic started by: Luis_Labarca on Aug 02, 2016, 05:15 AM

Title: [Solved]help in ini
Post by: Luis_Labarca on Aug 02, 2016, 05:15 AM
Hey guys I know where I am doing wrong?

probe with all functions of ini
to see if it was that, but nothing at all jump an error

This was what probe and errors that gave me
//-------------------------
WriteIniInteger ("Pos.ini", "Pos", player.Name, player.Pos);
AN ERROR HAS OCCURED [4 parameter has an invalid type 'instance'; expected: 'integer']
//-------------------------
WriteIniBool ("Pos.ini", "Pos", player.Name, player.Pos);
AN ERROR HAS OCCURED [4 parameter has an invalid type 'instance'; expected: 'bool']
//-------------------------
WriteIniString ("Pos.ini", "Pos", player.Name, player.Pos);
AN ERROR HAS OCCURED [4 parameter has an invalid type 'instance'; expected: 'string']
//-------------------------

also I put player.Pos.tointeger()
and player.Pos.tofloat()

and nothing jumps error

can you help me? thanks ;)
Title: Re: help in ini
Post by: MatheuS on Aug 02, 2016, 05:50 AM
WriteIniInteger ("Pos.ini", "Pos", player.) Name, player.Pos);
WriteIniInteger ("Pos.ini", "Pos", player.Name, player.Pos);

in all lines the error is this.
Title: Re: help in ini
Post by: Luis_Labarca on Aug 02, 2016, 06:01 AM
Quote from: MatheuS on Aug 02, 2016, 05:50 AMWriteIniInteger ("Pos.ini", "Pos", player.) Name, player.Pos);
WriteIniInteger ("Pos.ini", "Pos", player.Name, player.Pos);

in all lines the error is this.
Sorry bro was so player.) Name was because the translator the translation wrong and moved the) there but already fix it returns to look at


I get so and also gives error
Quote from: MatheuS on Aug 02, 2016, 05:50 AMWriteIniInteger ("Pos.ini", "Pos", player.Name, player.Pos);
error is  AN ERROR HAS OCCURED [parameter 4 has an invalid type 'instance' ; expected: 'integer']
Title: Re: help in ini
Post by: Thijn on Aug 02, 2016, 06:23 AM
What do you think that error means?
Title: Re: help in ini
Post by: Kewun on Aug 02, 2016, 06:28 AM
WriteIniNumber ("Pos.ini", "PosX", player.Name, player.Pos.x);
WriteIniNumber ("Pos.ini", "PosY", player.Name, player.Pos.y);
WriteIniNumber ("Pos.ini", "PosZ", player.Name, player.Pos.z);

use this, bro.

doesnt save all pos, but saves x, y, z.

and if u want load:

player.Pos.x = ReadIniNumber("Pos.ini","PosX",player.Name);
player.Pos.y = ReadIniNumber("Pos.ini", "PosY", player.Name);
player.Pos.z = ReadIniNumber("Pos.ini", "PosZ", player.Name);
Title: Re: help in ini
Post by: Luis_Labarca on Aug 02, 2016, 06:53 AM
Quote from: Kewun on Aug 02, 2016, 06:28 AMWriteIniNumber ("Pos.ini", "PosX", player.Name, player.Pos.x);
WriteIniNumber ("Pos.ini", "PosY", player.Name, player.Pos.y);
WriteIniNumber ("Pos.ini", "PosZ", player.Name, player.Pos.z);

use this, bro.

doesnt save all pos, but saves x, y, z.

and if u want load:

player.Pos.x = ReadIniNumber("Pos.ini","PosX",player.Name);
player.Pos.y = ReadIniNumber("Pos.ini", "PosY", player.Name);
player.Pos.z = ReadIniNumber("Pos.ini", "PosZ", player.Name);


oohh thank you friend if works me thanks bro thanks ;)

lol on wiki is wrong why is that I got bad WriteIniNumber this example an example of WriteIniInteger :-\



(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi68.tinypic.com%2F2jb18ns.jpg&hash=53b2d19aba6d6889f80d0d2cdf1e0fc1e4f19dc8)

Title: Re: help in ini
Post by: Luis_Labarca on Aug 02, 2016, 06:55 AM
Quote from: Thijn on Aug 02, 2016, 06:23 AMWhat do you think that error means?
problem solved :) is that wiki is wrong function in the function of wiki WriteIniNumber there is an example of the function WriteIniInteger

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi68.tinypic.com%2F2jb18ns.jpg&hash=53b2d19aba6d6889f80d0d2cdf1e0fc1e4f19dc8)
Title: Re: help in ini
Post by: Luis_Labarca on Aug 02, 2016, 07:15 AM
fix the problem on wiki thanks to all ;) :D ;D :)
Title: Re: help in ini
Post by: KAKAN on Aug 02, 2016, 08:38 AM
There's no problem with the wiki. Actually, player.Cash returns an int. But player.Pos returns an object containing X,Y,Z.
See the difference yourself:-
print( typeof player.Cash );
print( typeof player.Pos );
Title: Re: help in ini
Post by: EK.IceFlake on Aug 02, 2016, 09:50 AM
I recommend you use the squirrel source instead of the w!k!
Title: Re: help in ini
Post by: Luis_Labarca on Aug 02, 2016, 04:58 PM
Quote from: KAKAN on Aug 02, 2016, 08:38 AMThere's no problem with the wiki. Actually, player.Cash returns an int. But player.Pos returns an object containing X,Y,Z.
See the difference yourself:-
print( typeof player.Cash );
print( typeof player.Pos );
If it had regarded this photo as it was before in the wiki because that function in the wiki edit
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi68.tinypic.com%2F2jb18ns.jpg&hash=53b2d19aba6d6889f80d0d2cdf1e0fc1e4f19dc8)
Title: Re: help in ini
Post by: Luis_Labarca on Aug 02, 2016, 05:00 PM
Quote from: EK.CrystalBlue on Aug 02, 2016, 09:50 AMI recommend you use the squirrel source instead of the w!k!
ok bro thanks ;)
Title: Re: help in ini
Post by: Mötley on Aug 06, 2016, 02:34 PM
Well I will describe giving positions as fast as possible

Typically to give a player there position obviously you read there last position, but put those positions into arrays

so lets create some arrays

Pos_x <- array(GetMaxPlayers(), 0);
Pos_y <- array(GetMaxPlayers(), 0);
Pos_z <- array(GetMaxPlayers(), 0);

Okay now we can grab the data and store the global position's into there arrays.

Obviously this next part will be part of your login system. Thanks to Kewun for making this easier for me as I do not use ini anymore,.

On the Login

  Pos_x[player.ID] = ReadIniNumber("Pos.ini","PosX",player.Name);
  Pos_y[player.ID] = ReadIniNumber("Pos.ini", "PosY", player.Name);
  Pos_z[player.ID] = ReadIniNumber("Pos.ini", "PosZ", player.Name);

now you should create a function to see if the player is spawned on login, If they are and or when they do give the player there positions,

I will pretend we are only doing this on the login function "As if, are they spawned"

   if (player.Spawned) {
    player.Pos = Vector(Pos_x[player.ID], Pos_y[player.ID], Pos_z[player.ID]);
   }

now the player has been given there position,

now you need to make sure on what ever the function you created to give the player there skin position etc does NOT get loaded as this could be ugly as well a nightmare.

in this case maybe create an array and call in Reset on something, You can use this to reset weapons and much more in your actual data.

and if they died set that array to 1, then on there next spawn there special data in the arrays will get removed.

and for the spawn you could possibly use something similar to this

We will imagine this is hospital positions

Spawns <- [ Vector( 666.66, -666, 66.66 ), Vector( 666.6, -6666.5, 66.66 ), Vector( 66.66, -6666.6, 66.66 ), Vector( -66.66, -6666.6, 66.66 ) ];
Now you should make some validation on the spawn function
function onPlayerSpawn( player, Class ) {
        if (reset[player.ID] == 1) {
          local iRandom = ( GetTickCount() % 4 );
          Player.Pos = Spawns[ iRandom ];
          //you can reset much more hear
          MessagePlayer( "You have spawned", player );
       
         }
        //if not load the rest of there data
}

and thats a basic/shity example of how you should use position's. This is a basic issue I ran into in the past when using positions in ini days, I have not used positions in forever but I hope I was capable of helping you in future position scripting time. :)
Title: Re: help in ini
Post by: DizzasTeR on Aug 06, 2016, 03:37 PM
@Mötley
p_Pos <- array(GetMaxPlayers(), null);

/* ------------- */

local fX = ReadIniNumber("Pos.ini","PosX",player.Name), fY = ReadIniNumber("Pos.ini","PosY",player.Name), fZ = ReadIniNumber("Pos.ini","PosZ",player.Name);
p_Pos[ player.ID ] = Vector( fX, fY, fZ );

/* ------------- */

player.Pos = p_Pos[ player.ID ];
Title: Re: help in ini
Post by: Mötley on Aug 06, 2016, 04:10 PM
Quote from: Doom_Kill3R on Aug 06, 2016, 03:37 PM@Mötley
p_Pos <- array(GetMaxPlayers(), null);

/* ------------- */

local fX = ReadIniNumber("Pos.ini","PosX",player.Name), fY = ReadIniNumber("Pos.ini","PosY",player.Name), fZ = ReadIniNumber("Pos.ini","PosZ",player.Name);
p_Pos[ player.ID ] = Vector( fX, fY, fZ );

/* ------------- */

player.Pos = p_Pos[ player.ID ];

I like that method to,
The method i described is similar to the way I script. I just did not go fully in depth like i should have..

Title: Re: help in ini
Post by: Luis_Labarca on Aug 06, 2016, 06:39 PM
@Mötley @Doom_Kill3R problem solved thanks anyway ;)