[Solved]help in ini

Started by Luis_Labarca, Aug 02, 2016, 05:15 AM

Previous topic - Next topic

Luis_Labarca

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 ;)
My server RP
IP: 51.222.28.159:8194

MatheuS

#1
WriteIniInteger ("Pos.ini", "Pos", player.) Name, player.Pos);
WriteIniInteger ("Pos.ini", "Pos", player.Name, player.Pos);

in all lines the error is this.
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Luis_Labarca

#2
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']
My server RP
IP: 51.222.28.159:8194

Thijn

What do you think that error means?

Kewun

#4
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);

Luis_Labarca

#5
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 :-\





My server RP
IP: 51.222.28.159:8194

Luis_Labarca

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

My server RP
IP: 51.222.28.159:8194

Luis_Labarca

fix the problem on wiki thanks to all ;) :D ;D :)
My server RP
IP: 51.222.28.159:8194

KAKAN

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 );
oh no

EK.IceFlake

I recommend you use the squirrel source instead of the w!k!

Luis_Labarca

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
My server RP
IP: 51.222.28.159:8194

Luis_Labarca

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 ;)
My server RP
IP: 51.222.28.159:8194

Mötley

#12
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. :)

DizzasTeR

@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 ];

Mötley

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..