Scripting Help FAQ
#1

We all know the sorts of questions that come up time and time and time and time again! Yet there is no FAQ with a collection of neat answers following the latest techniques and best practices. It's time to put one together! Consider this a way to answer all those questions once and for all. Basically post any questions you've seen multiple times and if you can the best possible answers to them. Don't forget things like global naming conventions, libraries and plugins, pitfalls, options etc. Also, some of the answers will just be links to existing tutorials bringing the good ones together in to one handy reference.

Some questions to get this started:
  • Gates - HAS to be top of the list! Automatic, locked, button activated, command activated, rotating, sliding, lifting etc.
  • File saving - INI files, LOG files (very different formats and uses), write caches...
  • Colours.
  • Streaming.
  • Commands - (strcmp, dcmd, zcmd, y_commands, other), how to upgrade from one.
  • SQL queries (MySQL and SQLite).
I'll say now, I'm working on something BIG to address part of this problem (might need help with some parts if anyone is interested).
Reply
#2

Q: Where can I learn how to script?
A: There is already a beginner's introduction posted here. IMO, if you are new to the programming and have never seen nor written a piece of code, read this http://compuphase.com/pawn/Pawn_Getting_Started.pdf.
Topic: https://sampforum.blast.hk/showthread.php?tid=157611

Q: Help, warnings and errors!
A: https://sampforum.blast.hk/showthread.php?tid=274028.
Topic: https://sampforum.blast.hk/showthread.php?tid=338070&page=3

Q: What is the best command processor?
A: To clarify, a good command processor is one which offers speed and functionality. YCMD, ZCMD and rCMD are examples of up-to-date command processors.
Topic: https://sampforum.blast.hk/showthread.php?tid=312062

Q: Run time error 19: File or function not found!
A: This is a server error. It occurs upon server execution (hence a run time error) and when the server can't retrieve information from a plugin. A simple fix would be to make sure your plugins are in the correct directory (/plugins) and to also make sure it is added to server.cfg.
Topic: https://sampforum.blast.hk/showthread.php?tid=355115

Q: Problem with sscanf!
A: There is extensive documentation written about sscanf. If you have any issues, post in the topic section here.
Topic: https://sampforum.blast.hk/showthread.php?tid=339609

Q: MySQL vs SQLite
A: There has been countless threads on this; 1, 2, 3. Also, please take your time to read through the threads, as one's person's opinion isn't necessarily fact.
Topic: No original topic needed.

Q: Difference between Stock and Public functions.
A:
Quote:
Originally Posted by Y_Less
To clarify:

"stock" defines that a function may not be used, and if it isn't don't give a warning at compile time. This is used for library functions, you don't need it for writing normal modes.

"public" saves the name of the function in the amx (normally functions are just called be address, the human-readable name is not important). Saving the name means that the function can be found by name later on. When you specify a function in "SetTimer", "SetTimerEx", "CallLocalFunction" or "CallRemoteFunction" you specify it by name so these can only call public functions. Callbacks such as "OnPlayerConnect" are also public for the same reason.
Topic: https://sampforum.blast.hk/showthread.php?tid=171962

Q: Isn't foreach the same as a for loop!? (for loop vs foreach)
A:
Quote:
Originally Posted by Gh05t_
Foreach uses a method known as Linked Lists. Instead of each index validating a check of whether the player is connected or not, it stores the id of the next connected player. A separate variable stores the id of the first connected player, therefore, you may use the current index, to retrieve the next index and ONLY loop through connected players until it has been fulfilled (index of -1).
Topic: https://sampforum.blast.hk/showthread.php?tid=169782

Q: How to make a Register/Login script.
A: There are dozens of threads on the matter; 1, 2, 3, 4, 5.
Topic: https://sampforum.blast.hk/showthread.php?tid=278316

Q: Need help with a command!
A: If you need help with a command, post it here.
Topic: https://sampforum.blast.hk/showthread.php?tid=347955
Reply
#3

Scripting FAQ is definitely needed. The spam produced by asking/answering same questions over and over and over again in new topics is overwhelming.

Is this the thread where we can link new scripters to or is it just for gathering info for something else?

I'll add some here:

Q: Command not working / dialog not responding
A: You have a return 1 in OnPlayerCommandText / OnDialogResponse (in some other script) that blocks it. The last return in these callbacks should always be 0 in filterscripts.


Q: Where can I find interiors?
A: http://files.sa-mp.com/interiors.txt


Q: Where can I find custom SA-MP objects?
A: There should be SAMP.ide file in your GTA San Andreas folder (..\GTA San Andreas\SAMP\SAMP.ide). Open it with a text editor (Notepad)


Q: How can I get coordinates for a gang zone?
A: https://sampforum.blast.hk/showthread.php?tid=276352


Q: How can I make gang zones capturable?
A: https://sampforum.blast.hk/showthread.php?tid=276352


Q: Compiling gives "error 017: undefined symbol" when using a SA-MP native function
A: Download latest server package from http://www.sa-mp.com/download.php


Q: How can I get a random player?
A: https://sampforum.blast.hk/showthread.php?tid=352900
Reply
#4

I think this should be a sticked topic.


Q: How do I make movable gates/objects?
A: Checkout these tutorials:

- https://sampforum.blast.hk/showthread.php?tid=187713
- https://sampforum.blast.hk/showthread.php?tid=353988

Q: How many (vehicles/virtual worlds/map icons/menus..etc) can I have in my server?
A:

- https://sampwiki.blast.hk/wiki/Limits
- https://sampwiki.blast.hk/wiki/Talk:Limits


Q: I have too many objects/checkpoints and I want to add them all into my server, can I?
A: Yes you can. All you have to do is using a Streamer (Most used: Incognito's Streamer).


Q: Pawno crashes (and/or gives a 0kb .amx file) when compiling, how can I fix that?
A: You are probably missing something in your code (Usually a bracket) so try to find what's missing and fix it. If you couldn't solve the problem yourself, then you might post in the Scripting Help forum as long as you'll be following the RULES of it.


Q: How do I get the min and max X, Y, and/or Z co-ordinates for my gang zone, area ... etc?
A: Use this filterscript to get them easily.


Q: How to go to an interior using SA-MP Map Editor?
A:

#1 Open your SA-MP Map Editor.
#2 Click the Views tab
#3 Get the co-ordinates of the interior you want to go to (All interiors co-ordinates can be found here or here).
#4 Put them under Camera View .
#5 Click "Point camera at these Coords".
Reply
#5

Q: When I compile I get the "cannot read from file" error?

A: There are two things that could cause this.
  • You have multiple installations of Pawno.
    1. Go into your server directory.
    2. Double-click the folder 'pawno'.
    3. Open up pawno.exe
    4. Click the open icon.
    5. Access the script you are trying to compile.
    6. Compile.

  • The include is not in your pawno/includes folder.
    1. Pay attention to what the compiler says it cannot read from.
    2. Go into your server directory and access the pawno/includes folder.
    3. Make sure the file that is giving you the error is located in that folder.
    4. If it is, check the file extension. ( ie: ".txt" )
    5. Make sure the file extenstion is " .inc "
    6. If you don't have the file search for it on the internet and donwload it.
Reply
#6

Q: Help! Why do I get "Undefined symbol: mysql_query"?
A: BlueG's MySQL plugin R7 replaced mysql_query and mysql_query_callback from R6 and earlier with a new function: myqsl_function_query. Unthreaded queries are no longer supported. See AndreT's tutorial on how to use the new functions and the cache.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)