Need basic info
#1

Hello I wanted to learn basic scripting so can u just tell me a little about this things

1- what does Public means and what is its use?
2-what does Private means and what is its use?
3-what does callback means and what is its use?
4-what does Strings means and what is its use?

And if there is anything else u can tell pls tell me cause I really want to Learn scripting and programming
Reply
#2

https://sampwiki.blast.hk/wiki/Keywords:Initialisers
  1. Only use public functions for things that need to be "visible" to the server process. This is only the case for callbacks (see below), functions called by a timer and functions called by either CallLocalFunction or CallRemoteFunction.
  2. Pawn does not have a "private" keyword because it is not an object-oriented language. Variables are visible in the scope they're defined in. The "static" keyword comes closes to "private" because variables declared as static are only visible in the section (file) they're defined in.
  3. A callback is a function that is called by the server or a plugin. You (usually) don't call it directly from within the script (e.g. OnPlayerConnect). Names of callbacks will usually start with "On".
  4. A string is a sequence of (human readable) characters, i.e. text.
Reply
#3

There are different types of public's, each is used at one time, for example:


PHP код:
public OnPlayerConnect(playerid)
{
    new 
str[50];
    new 
Pname[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,Pname,MAX_PLAYER_NAME);
    
format(str,sizeof str,"The player %s has joined the server!",Pname);
    
SendClientMessageToAll(-1,str);
    return 
1;

Explanations:

Str[50];
A variable to host the other process, ie it is used as a labor in the process.

Pname[MAX_PLAYER_NAME];
Variable to get the name of the player that is connecting, and MAX_PLAYER_NAME is used.

GetPlayerName(playerid,Pname,MAX_PLAYER_NAME);
Will get the name of the player along with the variable we created Pname "...

format(str,sizeof str,
Is a parameter language it will format our variable containing the name of the player in %s is the name of the player formatted, this %s represents text, name, characters
among everything.


SendClientMessageToAll(-1,str);
Will give the formatted message, as we see atr, for all connected players, and that -1 is equal to white.

When the player exits the server

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
Pname[MAX_PLAYER_NAME];
    new 
str[128];
    
GetPlayerName(playerid,Pname,MAX_PLAYER_NAME);
    switch(
reason)
    {
        case 
0format(str,sizeof str,"Player% s left the server. reason(Lost connection / Crash)",Pname);
        case 
1format(str,sizeof str,"Player% s left the server. reason(Quit)",Pname);
        case 
2format(str,sizeof str,"Player %s left the server. reason(Kick /Ban)",Pname);
    }
    
SendClientMessageToAll(-1,str);
    return 
1;

CASE 0
When the connection of the player is bad and ends up falling, or his samp ends up giving crash.

CASE 1
The player's own will / q

CASE 2
When the player is kikado by an admin or banned "Server closed the connection"

When the player in your spawn is anywhere

PHP код:
public OnPlayerSpawn(playerid
{
    
GivePlayerWeapon(playerid24,6787);//Desert Eagle
    
GivePlayerWeapon(playerid26,8765);//Sawnoff Shotgun
    
return 1;

There is still a lot for you to learn friend, I recommend you go on the wifi samp and study the languages paramentros, strings etc .. will get you a lot in this samp world!

And for the improvement and ease of creating command save files use of paramentros I recommend you download these includes here:

Sscanf easy use of parameters such as / kick [id] [reason] By ******

DOF2 salvage of arquviso as: scores, deaths, kill .. By Double-O-Files.

Zcmd simple use in creating commands as we see in using By Zeex

Download

After downloading, you must extract from the winrar, and get the 3 files.inc and paste in / PAWNO / INCLUDE / paste here

Add the include to the top as we see:

Код:
#include <a_samp>
#include <DOF2>
#include sscanf
#include zcmd
After that compile your GM.

If it helped you + rep =D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)