OnPlayerConnect dont work... why? :c
#1

this is part of my GM

Код:
#include <a_samp>
#include <core>
#include <float>
#include <sscanf2>
#include <zcmd>
#include <mSelection>
#include "../include/gl_common.inc"

#pragma tabsize 0

//---------- COLORES -----------------------

#define COLOR_BLANCO 		0xFFFFFFFF
#define COLOR_ROJO          0xFFFF0000
#define COLOR_AZUL          0xFF0000FF
#define COLOR_AMARILLO      0xFFFFFF00
#define COLOR_VERDE         0xFF008000
#define COLOR_NARANJA       0xFFFFA500
#define COLOR_VERDECLARO    0xFFADFF2F
#define COLOR_TEJA          0xFF00FFFF
#define COLOR_GRIS          0xFF808080

//------------------------------------------

new DINERO_MATADOR=1000;
new DINERO_MUERTO=-1000;

new total_vehicles_from_files=0;
new skinlist = mS_INVALID_LISTID;
new skinactual[MAX_PLAYERS];
new bool: estado[MAX_PLAYERS];

//------------------------------------------

main( ) { }

//----------------------------------------------------------

public OnPlayerSpawn(playerid)
{
	SetPlayerInterior(playerid,0);
	TogglePlayerClock(playerid,0);
	SetPlayerSkin(playerid,skinactual[playerid]);
	if (GetPlayerMoney(playerid) < 0)
	{
		ResetPlayerMoney(playerid);
	}
	return 1;
}

//----------------------------------------------------------

public OnPlayerDeath(playerid, killerid, reason)
{
	//Bonificacion al Matador
	GivePlayerMoney(killerid,DINERO_MATADOR);
	SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
	//Acciones para el que Murio
	if (GetPlayerMoney(playerid) >= DINERO_MUERTO)
	{
		GivePlayerMoney(playerid,DINERO_MUERTO);
	}
   	return 1;
}

public OnPlayerConnect(playerid)
{
	GameTextForPlayer(playerid,"~g~~h~.::ASSHOLE::.",3000,0);
  	SendClientMessage(playerid,COLOR_BLANCO,"Bienvenido a {3ADF00}.::ASSHOLE::.");
	SetPlayerColor(playerid,COLOR_BLANCO);
	new mensaje[128], nombre[24];
	format(mensaje,128,"%s se ha conectado al servidor!",nombre);
	SendClientMessageToAll(COLOR_TEJA,mensaje);
	//---------- OTROS ----------
	estado[playerid] = true;
	print(mensaje);
 	return 1;
}
someone know about this?
i'm using: "print(mensaje);"
but not working wdf!
Reply
#2

Does it give you an error message when compiling? Or when you connect nothing happens?
Reply
#3

Quote:
Originally Posted by Nathan_Taylor
Посмотреть сообщение
Does it give you an error message when compiling? Or when you connect nothing happens?
the only event that does not work is "OnPlayerConnect(playerid)"
all others without any problem
0 errors when compiling :c
Reply
#4

pawn Код:
print(mensaje);
Should be
pawn Код:
print("mensaje");
Other than that I don't really see anything wrong.
Reply
#5

still not working
I do not understand why this happens T_T

this is my GM complete
i'm doing it from 0

Код:
#include <a_samp>
#include <core>
#include <float>
#include <sscanf2>
#include <zcmd>
#include <mSelection>
#include "../include/gl_common.inc"

#pragma tabsize 0

//---------- COLORES -----------------------

#define COLOR_BLANCO 		0xFFFFFFFF
#define COLOR_ROJO          0xFFFF0000
#define COLOR_AZUL          0xFF0000FF
#define COLOR_AMARILLO      0xFFFFFF00
#define COLOR_VERDE         0xFF008000
#define COLOR_NARANJA       0xFFFFA500
#define COLOR_VERDECLARO    0xFFADFF2F
#define COLOR_TEJA          0xFF00FFFF
#define COLOR_GRIS          0xFF808080

//------------------------------------------

new DINERO_MATADOR=1000;
new DINERO_MUERTO=-1000;

new total_vehicles_from_files=0;
new skinlist = mS_INVALID_LISTID;
new skinactual[MAX_PLAYERS];
new bool: estado[MAX_PLAYERS];

//------------------------------------------

main( ) { }

//----------------------------------------------------------

public OnPlayerSpawn(playerid)
{
	SetPlayerInterior(playerid,0);
	TogglePlayerClock(playerid,0);
	SetPlayerSkin(playerid,skinactual[playerid]);
	if (GetPlayerMoney(playerid) < 0)
	{
		ResetPlayerMoney(playerid);
	}
	return 1;
}

//----------------------------------------------------------

public OnPlayerDeath(playerid, killerid, reason)
{
	//Bonificacion al Matador
	GivePlayerMoney(killerid,DINERO_MATADOR);
	SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
	//Acciones para el que Murio
	if (GetPlayerMoney(playerid) >= DINERO_MUERTO)
	{
		GivePlayerMoney(playerid,DINERO_MUERTO);
	}
   	return 1;
}

public OnPlayerConnect(playerid)
{
	GameTextForPlayer(playerid,"~g~~h~.::ASSHOLE::.",3000,0);
  	SendClientMessage(playerid,COLOR_BLANCO,"Bienvenido a {3ADF00}.::ASSHOLE::.");
	SetPlayerColor(playerid,COLOR_BLANCO);
	new mensaje[128], nombre[24];
	format(mensaje,128,"%s se ha conectado al servidor!",nombre);
	SendClientMessageToAll(COLOR_TEJA,mensaje);
	//---------- OTROS ----------
	estado[playerid] = true;
	print("mensaje");
 	return 1;
}

//----------------COMANDOS----------------------

CMD:sumar(playerid, params[])
{
	new v1, v2;
	if(sscanf(params,"dd", v1, v2))return SendClientMessage(playerid, COLOR_VERDECLARO, "[KE]: Como usar: '/sumar [valor1] [valor2]'");
	new r=v1+v2;
	new resultado[30];
	format(resultado,30,"El Resultado es: %d",r);
	SendClientMessage(playerid,COLOR_BLANCO,resultado);
	return 1;
}

CMD:kill(playerid, params[])
{
    SetPlayerHealth(playerid,0);
}

//----------------------------------------------------------

public OnPlayerRequestClass(playerid, classid)
{
    TogglePlayerSpectating(playerid, true);
    ShowModelSelectionMenu(playerid, skinlist, "Select Skin");
    return 1;
}

//----------------------------------------------------------

public OnPlayerModelSelection(playerid, response, listid, modelid)
{
    if(listid == skinlist)
    {
        if(response)
        {
            TogglePlayerSpectating(playerid, false);
            SpawnPlayer(playerid);
            SetPlayerSkin(playerid, modelid);
            skinactual[playerid] = modelid;
            SetPlayerPos(playerid, 2023.5839, 1545.2329, 10.8205);
           	if (estado[playerid] == true)
  			{
  				GivePlayerWeapon(playerid,WEAPON_BAT,1);
				GivePlayerWeapon(playerid,WEAPON_COLT45,1);
				GivePlayerMoney(playerid,5000);
				SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,200);
  			}
        }
        else ShowModelSelectionMenu(playerid, skinlist, "Select Skin");
        return 1;
    }
    return 1;
}

//----------------------------------------------------------

public OnGameModeInit()
{
	SetGameModeText(".::ASSHOLE::.");
	ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL);
	UsePlayerPedAnims();
	ShowNameTags(1);
	SetNameTagDrawDistance(50.0);
	EnableStuntBonusForAll(1);
	//DisableInteriorEnterExits();
	SetWeather(2);
	SetWorldTime(10);
	UsePlayerPedAnims();
	//ManualVehicleEngineAndLights();

	// Player Class
	skinlist = LoadModelSelectionMenu("skins.txt");
	
	// SPECIAL
	total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/trains.txt");
	total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt");

   	// LAS VENTURAS
     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt");
    
    // SAN FIERRO
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");
    
    // LOS SANTOS
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");
    
    // OTHER AREAS
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt");

    printf("Total vehicles from files: %d",total_vehicles_from_files);
	return 1;
}

//----------------------------------------------------------

public OnPlayerUpdate(playerid)
{
	if(!IsPlayerConnected(playerid)) return 0;
	// No weapons in interiors
	if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0)
	{
	    SetPlayerArmedWeapon(playerid,0);
	}
	else
	{
	    SetPlayerArmedWeapon(playerid,1);
	}
	
	if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN)
	{
		SendClientMessage(playerid,COLOR_ROJO,"[KE]: no se permite minigun!");
	    Kick(playerid);
	    return 0;
	}
	
	/* No jetpacks allowed
	if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) {
	    Kick(playerid);
	    return 0;
	}*/

	return 1;
}
Reply
#6

I didn't realize that you were trying to print the message text, you should use printf.
pawn Код:
public OnPlayerConnect(playerid)
{
    GameTextForPlayer(playerid,"~g~~h~.::ASSHOLE::.",3000,0);
    SendClientMessage(playerid,COLOR_BLANCO,"Bienvenido a {3ADF00}.::ASSHOLE::.");
    SetPlayerColor(playerid,COLOR_BLANCO);
    new mensaje[128], nombre[24];
    format(mensaje,128,"%s se ha conectado al servidor!",nombre);
    SendClientMessageToAll(COLOR_TEJA,mensaje);
    //---------- OTROS ----------
    estado[playerid] = true;
    printf("%s", mensaje);
    return 1;
}
Just to clarify on what error you are having, when someone connects to your server does the gametext or client message, and the "nombre se ha conectado al servidor!" messages show up? Or you just want the print(); line to work right?
Reply
#7

Quote:
Originally Posted by Nathan_Taylor
Посмотреть сообщение
I didn't realize that you were trying to print the message text, you should use printf.
pawn Код:
public OnPlayerConnect(playerid)
{
    GameTextForPlayer(playerid,"~g~~h~.::ASSHOLE::.",3000,0);
    SendClientMessage(playerid,COLOR_BLANCO,"Bienvenido a {3ADF00}.::ASSHOLE::.");
    SetPlayerColor(playerid,COLOR_BLANCO);
    new mensaje[128], nombre[24];
    format(mensaje,128,"%s se ha conectado al servidor!",nombre);
    SendClientMessageToAll(COLOR_TEJA,mensaje);
    //---------- OTROS ----------
    estado[playerid] = true;
    printf("%s", mensaje);
    return 1;
}
Just to clarify on what error you are having, when someone connects to your server does the gametext or client message, and the "nombre se ha conectado al servidor!" messages show up? Or you just want the print(); line to work right?
none of the messages shown
in conclusion, nothing is executed within the event
Reply
#8

Try doing
pawn Код:
public OnPlayerConnect(playerid)
{
    print("OnPlayerConnect Called");
    return 1;
}
and see if it works, then add each line and try again until it stops working, then that will tell you what is messing it up. If that doens't help, then I'm sorry but this is out of my league :P
Reply
#9

still not working T_T
I do not understand what happens here :S

--------------------------------------------------------------------

EDIT: the event in a filterscrip yes works
not understand why the Event in GM does not work

Thanks for your time friend
I'll have to make my actions from a filterscrip
Reply
#10

Is OnPlayerConnect callback is even being called?

The variable nombre[24] is not even getting the player name.

More info on the wiki.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)