Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Код:
SomeFunction(maybe, some, parameters);
{
   SendClientMessage(maybe, COLOR_SOME, "Text");
}
Can make your compiler go bananas and you end up spending some great time on finding what the heck is wrong since the compiler just stops working. Eventually you see that you added an unnecessary semicolon to the function. Sadly this has happened to me in the past but I had forgotten what it was, luckily it didn't take way too long time figuring it out since I had been compiling frequently!

Protip: Compile as much as you can! :P
I frequently diff and read all changes between HEAD HEAD^ if I can't solve the errors within seconds.
Reply

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Код:
SomeFunction(maybe, some, parameters);
{
   SendClientMessage(maybe, COLOR_SOME, "Text");
}
Can make your compiler go bananas and you end up spending some great time on finding what the heck is wrong since the compiler just stops working. Eventually you see that you added an unnecessary semicolon to the function. Sadly this has happened to me in the past but I had forgotten what it was, luckily it didn't take way too long time figuring it out since I had been compiling frequently!

Protip: Compile as much as you can! :P
These things happen with me frequently, usually in format when i have too much parameters, sometimes i miss a comma, or some times a parenthesis. But, the major problem pawno gives irreleavent errors.
Reply

today I learned this:

PHP код:
for (new 0!= 10i++)
    for (new 
0!= 100j++)
        Function(
ij); 
is faster then:

PHP код:
for (new 0!= 100j++)
    for (new 
0!= 10i++)
        Function(
ij); 
because the inner loop always jumps 10*100 times, but the outer loop jumps different time. top code so jumps 10+10*100 times, bottom code so jumps 100+100*10 times. the less loop should be outer loop.
Reply

Today I learned how can i move entire maps to another place. Without remapping.
Reply

Quote:
Originally Posted by coool
Посмотреть сообщение
Today I learned how can i move entire maps to another place. Without remapping.
Care to say how?
Reply

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Care to say how?
https://sampforum.blast.hk/showthread.php?tid=506610
Reply

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Care to say how?
You may use the below given fs for general purpose or my way for undetermined position of objects. Objects which you want to create at any place.
Quote:
Originally Posted by CheezIt
Посмотреть сообщение
Nice but i use my way when i have to create many objects in front OF PLAYER, and a player can be at any place. I use this way (maybe performance consuming)
Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z); //You may change x, y and z value according to your needs.
//By the way you should also take a look at GetXYInFrontOfPlayer. Or change x,y,z according to your needs.
CreateObject(modelid, x, y, z); //This object will be create on player's pos.
CreateObject(modelid, 211 - 214 + x, 384 - 390 + y, 10 - 8 + z); //This will be created in its same pos as it was before.
//211[1st object's x] 214 [2nd object's x] Similarly to y and z;
I do not think it is a good idea. Maybe there is another way to do it.
Reply

Today I learned (or figured out) how to write a fully generic parameters passing library, so you can FINALLY do this:

PHP код:
#include <a_samp>
#include <YSI_Coding\y_va2>

main()
{
    
MyFunc1("Hello""there""world");
}

MyFunc1(...)
{
    
MyFunc2(___);
}

MyFunc2(...)
{
    
printf("%s %s %s"___);

That triple underscore (chosen as it mirrors the triple dots and the single underscore used to set parameters to their defaults, an obscure piece of syntax) will correctly forward ALL the given parameters on to the next parameter without any extra effort required on the part of the function writer. This totally replaces y_va and other solutions that did complex things like totally wrapping certain functions or other complex assembly solutions.

In short, "___" calls a function that takes all the paramters from the parent function and duplicates them on the stack - it is actually quite simple in retrospect. There are some tricky bits to get right to support recursive calls, and nested calls like:

PHP код:
Func1(Func2(___), ___); 
But I know how to solve these.
Reply

That would seriously print Hello there world? That's really great!
Reply

Quote:
Originally Posted by Y_Less
Посмотреть сообщение
Today I learned (or figured out) how to write a fully generic parameters passing library, so you can FINALLY do this:

PHP код:
#include <a_samp>
#include <YSI_Coding\y_va2>
main()
{
    
MyFunc1("Hello""there""world");
}
MyFunc1(...)
{
    
MyFunc2(___);
}
MyFunc2(...)
{
    
printf("%s %s %s"___);

That triple underscore (chosen as it mirrors the triple dots and the single underscore used to set parameters to their defaults, an obscure piece of syntax) will correctly forward ALL the given parameters on to the next parameter without any extra effort required on the part of the function writer. This totally replaces y_va and other solutions that did complex things like totally wrapping certain functions or other complex assembly solutions.

In short, "___" calls a function that takes all the paramters from the parent function and duplicates them on the stack - it is actually quite simple in retrospect. There are some tricky bits to get right to support recursive calls, and nested calls like:

PHP код:
Func1(Func2(___), ___); 
But I know how to solve these.
You're back? Lol.
Reply

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
That would seriously print Hello there world? That's really great!
Yes:



Quote:
Originally Posted by Arithmetic
Посмотреть сообщение
You're back? Lol.
No
Reply

Quote:
Originally Posted by Y_Less
Посмотреть сообщение
...
I seriously don't get why you didn't and don't create a server? What you did and are doing seems more like a waste of time than anything else, really.
Reply

Quote:
Originally Posted by CheezIt
Посмотреть сообщение
What you did and are doing seems more like a waste of time than anything else, really.
No it's not . its called love towards programming and eager to explore a language.
Reply

I'd be terrible at writing and managing a server - there is far more to it than just knowing the language well, in fact I'd say the two are entirely unrelated. I am good at, and enjoy writing, back-end systems and solving interesting problems. I have no interest in spending hours tweaking object placements and text draw colours, but will happily give others the tools to do so.

I've actually tried writing a server several times. The first time I spent all the time on the underlying systems and eventually released them all as YSI. Second time I again spent ages writing a system so that I could just take existing gamemodes, include multiple ones in to a single script, and load them all at once and totally independently. Functions were wrapped so each mode behaved exactly like they were the only code running on a small server, but loads could run at once in parallel with different isolated players. After I got that working, I again had no interest in carrying that through to a fully running mini-mode server.

I have released two bad small modes (Military Hardware, a UT-assault-esque team game; and Level Lord, a king-of-the-hill deathmatch). But now I can't even remember the last time I had San Andreas installed...

Servers are much more about aesthetics and fun, what I do is more about logical challenges with answers, they are different.
Reply

Quote:
Originally Posted by Y_Less
Посмотреть сообщение
...
Haha, I thought I was the only one. I have never owned a live server and haven't played SA-MP properly in literally years. I just like the challenges and put everything I create together in an offline script. I just like programming I guess. I completely understand.
Reply

Reply

Quote:
Originally Posted by ISmokezU
View Post
I didn't learn this today but what the heck.

TIL:

Instead of doing this:

PHP Code:
CMD:ban(playeridparams[]) 
{
     
//Code...
}
CMD:sban(playeridparams[])
{
    
//Code...

It can be combine with:

PHP Code:
CMD:ban(playeridparams[])
{
    
//Code...
    
if(!strcmp(params"/sban")) 
    {
       
//Code...
    
}

lmao are you ok
Reply

Quote:
Originally Posted by TommyB
View Post
lmao are you ok
i dont think he is
lets make him a sasd leader tommy

eksde
Reply

Programming a server > Playing on the server
Reply

I know this isn't related to scripting per say but I'm not sure there's a thread about SA-MP tricks and tips, or whatever. I'll just post it here and hope it will help someone one day.

I was trying overclocking (obviously needed for other games than San Andreas) for the first time today and apparently that might have messed up some of my settings. I am always prompted with this box when I want to join a server, which I'm not sure why, this only happened after I installed Windows 10.



But instead I was given a lower resolution as default this time:


So I started testing things out, trying to set it back and rejoin a couple of times and so on but nothing worked. Eventually I tried to go my old resolution (bigger one) and set the resolution in-game to the smaller resolution, clicking enter to apply the changes and then change back to the resolution I want (the bigger one). That seemed to work and next time I tried to join a server it was back to the settings I preferred.

In-game fix: Press ESC -> Options -> Display Setup -> Advanced -> Change Resolution to lower -> Hit enter -> Change Resolution back to the one you wish to have (you don't have to exit the menu) -> Hit enter -> Restart San Andreas and it should pop up normally again.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)