OnPlayerConnect not called?
#1

My OnPlayerConnect-script is apparantly never called - none of the functions I added are functioning in game.

I'll supply my script and see if you can find the mistake I made, and if someone would like to optimize my code or point out errors, please do so. I always appreciate constructive criticism.

I'm aware the mistake is probably something small and obvious - I just don't know what, at this moment.

(inb4 "get mysql")

pawn Код:
public OnPlayerConnect(playerid)
{
    Inst::OnPlayerConnect(playerid);
   
    new fil[128];
    format(fil,sizeof(fil),"IPBans.ini");
    new PIP[MAX_STRING];
    GetPlayerIp(playerid,PIP,sizeof(PIP));
    if(dini_Int(fil, PIP) == 1)
    {
        SendClientMessage(playerid, COLOR_BRIGHTRED, "-----------------------------------------------------------------------------------------");
        SendClientMessageFormatted(playerid, COLOR_BRIGHTRED, "Your IP (%s) is permanently banned from the server.", PIP);
        SendClientMessage(playerid, COLOR_BRIGHTRED, "To post an unban appeal, visit -INSERT WEBSITE-");
        SendClientMessage(playerid, COLOR_BRIGHTRED, "-----------------------------------------------------------------------------------------");
        Kick(playerid);
        return 1;
    }

    if(IsPlayerNPC(playerid)) return IsLogged[playerid] = 1;
    TextDrawShowForPlayer(playerid, CSRPWeb);

    if(PlayerFaction[playerid][Faction] == FACTION_NONE) SetPlayerColor(playerid, COLOR_WHITE);
    if(PlayerFaction[playerid][Faction] == FACTION_CW) SetPlayerColor(playerid, COLOR_CW);
    if(PlayerFaction[playerid][Faction] == FACTION_LAW) SetPlayerColor(playerid, COLOR_LAW);
    if(PlayerFaction[playerid][Faction] == FACTION_FATAL) SetPlayerColor(playerid, COLOR_BRIGHTRED);
    if(PlayerFaction[playerid][Faction] == FACTION_CERS) SetPlayerColor(playerid, COLOR_CERS);
    if(PlayerFaction[playerid][Faction] == FACTION_MUTANT) SetPlayerColor(playerid, COLOR_MUTANT);
    if(PlayerFaction[playerid][Faction] == FACTION_BANDITS) SetPlayerColor(playerid, COLOR_BANDITS);
    if(PlayerInfo[playerid][Outlaw] == 1) SetPlayerColor(playerid, COLOR_OUTLAW);

    // General Variables
    IsLogged[playerid] = 0;
    IsPlayerOnQuest[playerid] = 0;
    PlayerInfo[playerid][AFKStatus] = 0;
    PlayerInfo[playerid][Godmode] = 0;
    FailedLogins[playerid] = 0;

    new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(strfind(name, "_", true) == -1)
    {
        new string[128];
        format(string,sizeof(string),"» Wrong name format: '%s'",name);
        SendClientMessage(playerid, COLOR_RED, "-----------------------------------------------------------------------------------------");
        SendClientMessage(playerid, COLOR_WHITE, string);
        SendClientMessage(playerid, COLOR_WHITE, "Name must be 'Firstname_Lastname'! Please reconnect with a new name.");
        SendClientMessage(playerid, COLOR_RED, "-----------------------------------------------------------------------------------------");
        Kick(playerid);
    }
    format(file,sizeof(file),"Accounts/%s.ini",name);
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Create an account", "This username is not registered.\n\nPlease choose a password to register.\n\nYour password must be between 5 and 20 letters.\nIt may contain both numbers and letters.", "Register", "Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login to your account", "This account is registered.\n\nPlease login with your password below.\n\nIf you did not register this account, please press 'Quit'.", "Login", "Quit");
    }

    CashCounter[playerid] = TextDrawCreate(529.000000, 78.000000, "123456789");
    TextDrawBackgroundColor(CashCounter[playerid], 255);
    TextDrawFont(CashCounter[playerid], 1);
    TextDrawLetterSize(CashCounter[playerid], 0.409999, 2.100000);
    TextDrawColor(CashCounter[playerid], 345901311);
    TextDrawSetOutline(CashCounter[playerid], 0);
    TextDrawSetProportional(CashCounter[playerid], 1);
    TextDrawSetShadow(CashCounter[playerid], 1);

    CurrentXP[playerid] = TextDrawCreate(525.000000, 124.000000, "CURNTX");
    TextDrawBackgroundColor(CurrentXP[playerid], 255);
    TextDrawFont(CurrentXP[playerid], 1);
    TextDrawLetterSize(CurrentXP[playerid], 0.260000, 1.000000);
    TextDrawColor(CurrentXP[playerid], -1);
    TextDrawSetOutline(CurrentXP[playerid], 0);
    TextDrawSetProportional(CurrentXP[playerid], 1);
    TextDrawSetShadow(CurrentXP[playerid], 1);

    GoalXP[playerid] = TextDrawCreate(562.000000, 124.000000, "/ GOALXP");
    TextDrawBackgroundColor(GoalXP[playerid], 255);
    TextDrawFont(GoalXP[playerid], 1);
    TextDrawLetterSize(GoalXP[playerid], 0.260000, 1.000000);
    TextDrawColor(GoalXP[playerid], -1);
    TextDrawSetOutline(GoalXP[playerid], 0);
    TextDrawSetProportional(GoalXP[playerid], 1);
    TextDrawSetShadow(GoalXP[playerid], 1);

    SetTimerEx("Textdraws", 1000, 0, "%d", playerid);
    return 1;
}
Reply
#2

Add debug lines to find the origin of your problem.
Reply
#3

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
Add debug lines to find the origin of your problem.
Somewhere in the beginning, possibly the IP-ban part. The Firstname_Lastname check isn't called, so it's before that.
Reply
#4

Maybe its
pawn Код:
Inst::OnPlayerConnect(playerid);
Reply
#5

Possible - I need that line for the InstaGib-include though. :/

EDIT: I'll test it in an hour and report back.
Reply
#6

Sorry for doubleposting.

Yes, InstaGib did the trick. It works when I removed that. However, how will I get that include to work now?

http://forum.sa-mp.com/showthread.ph...ght=bot+weapon

Anyone interested could check this bookmark of mine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)