Need basic info
#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


Messages In This Thread
Need basic info - by Advait - 28.05.2017, 13:43
Re: Need basic info - by Vince - 28.05.2017, 13:51
Re: Need basic info - by DarkBr - 28.05.2017, 16:30

Forum Jump:


Users browsing this thread: 1 Guest(s)