Little coding questions - For general minor queries 5

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
so this works
pawn Код:
new blabla[max_blas] = {-1, ...};
how do I do this..
pawn Код:
new blabla[max_blas][max_blas] = {-1, ...};
Something like this, I believe:

pawn Код:
new blabla[max_blas][max_blas] = { { -1, 0, 1 }, { -1, 0, 1 } ...};
Where { -1, 0, 1 } is the first dimension , and the values in the first dimension are represented as the second dimension (blabla[firstDimension][secondDimension]). Correct me if I'm wrong.
Reply

Quote:
Originally Posted by Overhaul
Посмотреть сообщение
Something like this, I believe:

pawn Код:
new blabla[max_blas][max_blas] = { { -1, 0, 1 }, { -1, 0, 1 } ...};
Where { -1, 0, 1 } is the first dimension , and the values in the first dimension are represented as the second dimension (blabla[firstDimension][secondDimension]). Correct me if I'm wrong.
Nah, Gives an error..
Reply

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Nah, Gives an error..
That was an example to give you an idea how it works. Consider the following:
PHP код:
enum E_BlaBla {
    
    
enumerator1,
    
enumerator2,
    
enumerator3
};
new 
BlaBla[][E_BlaBla] = {
    { 
value1value2value3 },
    { 
value1value2value3 },
    { 
value1value2value3 }
}; 
Reply

Quote:
Originally Posted by Overhaul
Посмотреть сообщение
That was an example to give you an idea how it works. Consider the following:
PHP код:
enum E_BlaBla {
    
    
parameter1,
    
parameter2,
    
parameter3
};
new 
BlaBla[][E_BlaBla] = {
    { 
value1value2value3 },
    { 
value1value2value3 },
    { 
value1value2value3 }
}; 
I'm trying to assign a default value to variables when making them
pawn Код:
new something[MAX_PLAYERS][MAX_PLAYERS];
How can I use your example for that ? ..
Reply

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
I'm trying to assign a default value to variables when making them
pawn Код:
new something[MAX_PLAYERS][MAX_PLAYERS];
How can I use your example for that ? ..
I assume that the usage of MAX_PLAYERS in your given example is just an example.

PHP код:
new BlaBla[][] = {
    { 
index0index2index3 }, // Index '0' in the first dimension
    
index1index2index3 }, // Index '1' in the first dimension
    
index1index2index3 }    // Index '2' in the first dimension
};
// Replace the index's with your values.
BlaBla[0][2// Will have the value of index3 in index '0' in the first dimension. 
I am still quite unsure on what you're exactly trying to do.
Reply

I believe it's 1559. At least, according to the SA:MP Wiki that's what it seems like...
Reply

Yeah, But it's way smaller, how increase it's size...
Reply

I don't believe that you can.
Reply

So, I own a small server with 25 slots. Currently I'm using Y_INI to store player accounts. At this moment, when a player joins a server it loads his account file, which contains 72 (sic!) integers. Same thing happens when he leaves the server - it saves 72 integers. (yep, all of them are important)
The question is - could this big amount of data to save cause some serious lag? Should I switch to MySQL?
Reply

No. The only real use for MySQL when it comes to SA:MP is if you want to have a quick and easy online user control panel. Writing to a file using y_INI is so much faster than querying a server.

The only reason many people use MySQL besides what I stated above is ease-of-use and the fact that the data can be stored and organized very easily.
Reply

pawn Код:
new Text3D: test = INVALID_3DTEXT_ID;
- tag mismatch.

Is it possible to avoid that?

edit: there is a solution.

pawn Код:
new Text3D: test = Text3D: INVALID_3DTEXT_ID;
Reply

Quote:
Originally Posted by b3nz
Посмотреть сообщение
pawn Код:
new Text3D: test = INVALID_3DTEXT_ID;
- tag mismatch.

Is it possible to avoid that?
Use
pawn Код:
new Text3D: test = Text3D: INVALID_3DTEXT_ID;
EDIT: Oops, too late.
Reply

pawn Код:
GetPlayerPos(playerid, x, y, z);//Is there a way to get only the "z" and skip getting the x, y ?
Reply

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
pawn Код:
GetPlayerPos(playerid, x, y, z);//Is there a way to get only the "z" and skip getting the x, y ?
Код:
GetPlayerPos(playerid, z, z, z);
Reply

Quote:
Originally Posted by X337
Посмотреть сообщение
Код:
GetPlayerPos(playerid, z, z, z);
What if I want the Y, one will probably overwrite the other..
Reply

Why not just store all the positions? This won't hurt the server's performance at all, it's just a bit more memory which is not noticeable at all.

You can also try something such as this to return just the Y:
pawn Код:
Float:returnYPos(playerid)
{
      new Float: x, Float: y, Float: z;
      GetPlayerPos(playerid, x, y, z);

      return y;
}
Reply

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Why not just store all the positions? This won't hurt the server's performance at all, it's just a bit more memory which is not noticeable at all.

You can also try something such as this to return just the Y:
pawn Код:
Float:returnYPos(playerid)
{
      new Float: x, Float: y, Float: z;
      GetPlayerPos(playerid, x, y, z);

      return y;
}
Taking unnecessary space in my code and memory, not much but if there's a way to just get what I want would be great, looks like there isn't though(despite using a stock) , thanks anyway.
Reply

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
pawn Код:
GetPlayerPos(playerid, x, y, z);//Is there a way to get only the "z" and skip getting the x, y ?
Maybe
PHP код:
GetPlayerPos(playerid__z); 
Reply

That won't work because the function doesn't have a default value. It will give a "argument does not have a default value" error and will refuse to compile.
Reply

Quote:
Originally Posted by Abagail
Посмотреть сообщение
That won't work because the function doesn't have a default value. It will give a "argument does not have a default value" error and will refuse to compile.
Does that mean if I hook a function and add a default value(I'm not even sure you can add a default value to a returning value), that will make the example above you possible ?

Also how do I add spaces in a string and show it, like "....example"(replace the dots with spaces)(Wow, I can't even do it in here), I think samp treats this as empty because the first character is a space
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)