SA-MP Forums Archive
Little coding questions - For general minor queries 5 - 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: Little coding questions - For general minor queries 5 (/showthread.php?tid=30938)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46


Re: Little coding questions - For general minor queries 5 - Overhaul - 28.07.2015

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.


Re: Little coding questions - For general minor queries 5 - xVIP3Rx - 28.07.2015

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


Re: Little coding questions - For general minor queries 5 - Overhaul - 28.07.2015

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 }
}; 



Re: Little coding questions - For general minor queries 5 - xVIP3Rx - 28.07.2015

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


Re: Little coding questions - For general minor queries 5 - Overhaul - 28.07.2015

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.


Re: Little coding questions - For general minor queries 5 - Scenario - 02.08.2015

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


Re: Little coding questions - For general minor queries 5 - xVIP3Rx - 02.08.2015

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


Re: Little coding questions - For general minor queries 5 - Scenario - 02.08.2015

I don't believe that you can.


Re: Little coding questions - For general minor queries 5 - Amads - 02.08.2015

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?


Re: Little coding questions - For general minor queries 5 - Scenario - 02.08.2015

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.


Re: Little coding questions - For general minor queries 5 - b3nz - 06.08.2015

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;



Re: Little coding questions - For general minor queries 5 - IstuntmanI - 06.08.2015

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.


Re: Little coding questions - For general minor queries 5 - xVIP3Rx - 07.08.2015

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



Re: Little coding questions - For general minor queries 5 - X337 - 07.08.2015

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



Re: Little coding questions - For general minor queries 5 - xVIP3Rx - 07.08.2015

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


Re: Little coding questions - For general minor queries 5 - Abagail - 07.08.2015

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;
}



Re: Little coding questions - For general minor queries 5 - xVIP3Rx - 07.08.2015

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.


Re: Little coding questions - For general minor queries 5 - SyneR - 07.08.2015

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



Re: Little coding questions - For general minor queries 5 - Abagail - 07.08.2015

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.


Re: Little coding questions - For general minor queries 5 - xVIP3Rx - 08.08.2015

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