well everything works fine but onplayerconnect isnt working i mean when player connect mysql doesnt check accounts no query even i checked mysql logs and also no gang zones show for player nothing works in onplayerconnect and also when i connect to me server it says request connection cookie i never had anything like this before
PHP код:
//Checking player's account if they are registered or not.
function OnPlayerConnect(playerid)
{
new query[228], str[64], joinMsg[128], name[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
for(new PDATA:e; e < PDATA; ++e)
{
pInfo[playerid][e] = 0;
}
for(new BANINFO:e; e < BANINFO; ++e)
{
bInfo[playerid][e] = 0;
}
inJail[playerid] = 0;
//
LoginAttempt[playerid] = 0;
//
Muted[playerid] = false;
//
AutoRepair[playerid] = 1;
//
pMG_Minigame[playerid] = false;
//
BadWeaponsAllowed[playerid] = false;
//
PlayerProps[playerid] = 0;
//
EarningsForPlayer[playerid] = 0;
//
gNameTags[playerid] = 1;
//
AimbotWarnings[playerid] = 0;
//
g_MysqlRaceCheck[playerid]++;
//
ShowGlobalTextdraws(playerid);
//
CreatePlayerTextdraw(playerid);
//
pInfo[playerid][Money] = 0;
for( new i ,slots = GetMaxPlayers(); i < slots; i++ )
{
if(IsPlayerConnected(i))
{
pcounters[playerid]++;
}
if(pcounters[i])
{
new strd[8];
format(strd, sizeof(strd), "%d/%d", pcounters, GetMaxPlayers());
TextDrawSetString(TDEditor_TD[2], strd);
}
else
{
TextDrawSetString(TDEditor_TD[2], "0/30");
}
}
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `bans` WHERE `Username` = '%e'", GetName(playerid));
mysql_tquery(mysql, query, "OnPlayerCheckBan", "d", playerid);
mysql_format(mysql, query, sizeof(query),"INSERT INTO `ip` (`IP`, `Username`) VALUES ('%s','%s')",GetPlIP(playerid),GetName(playerid));
mysql_tquery(mysql, query,"","");
ShowPlayerTextdraw(playerid);
new mysqlquery[200];
mysql_format(mysql, mysqlquery, sizeof(mysqlquery), "SELECT c.country_name FROM list_ipv4 i JOIN list_countries c ON i.country_code = c.country_code WHERE INET_ATON('%e') BETWEEN range_start AND range_end;", IP[playerid]);
mysql_tquery(mysql, mysqlquery, "GetCountryName", "d", playerid);
GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
GetPlayerIp(playerid, IP[playerid], 16); //Getting layer's IP forgot this part, now it shoul save
format(str,sizeof(str),""HostURL"%s",IP[playerid]);
HTTP(playerid, HTTP_GET, str, "", "IRCOnHostResponse");
pInfo[playerid][ConnectTime] = gettime(); //gettime (); = is the amount of seconds since 1970
//LoadPlayerTextDraws(playerid);
RemoveBuildingForPlayer(playerid, 1302, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 1209, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 955, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 956, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 1775, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 1776, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 1977, 0.0, 0.0, 0.0, 6000.0);
// ShowGloablTextdraws(playerid);
printf("IP on connect: %s", IP[playerid]); //check this. brb in 15-20 mins ok
mysql_format(mysql, query, sizeof(query),"SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(mysql, query, "OnAccountCheck", "dd", playerid,g_MysqlRaceCheck[playerid]);
GetPlayerName(playerid, name, sizeof(name));
format(joinMsg, sizeof(joinMsg), "02[%d] 03*** %s has joined the server.", playerid, name);
IRC_GroupSay(groupID, IRC_CHANNEL, joinMsg);
SendClientMessage(playerid, COLOR_WHITE, "Welcome to "COL_RED"eXtreme Multi Stunts server "COL_WHITE"(/help)");
SendClientMessage(playerid, COLOR_WHITE, "Please read "COL_RED"/rules /commands "COL_WHITE"to explore our server");
GangZoneShowForAll(GZ_ZONE2, 0xFE5F6366);
GangZoneShowForAll(GZ_ZONE1, 0xFE5F6366);
GangZoneShowForAll(GZ_ZONE3, 0xFE5F6366);
SendDeathMessage(INVALID_PLAYER_ID, playerid, 200); // connect
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
for(new propid; propid < PropertiesAmount; propid++)
{
if(PropInfo[propid][PropIsBought] == 1)
{
if(strcmp(PropInfo[propid][PropOwner], pName, true)==0)
{
EarningsForPlayer[playerid] += PropInfo[propid][PropEarning];
PlayerProps[playerid]++;
}
}
}
/*for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gNameTags[i] == 0)
ShowPlayerNameTagForPlayer(i, playerid, 0);
}*/
return 1;
}
Are you using mysql_connect on ongamemodeinit ? If not you need to connect to your database before the other things.
It is probably cause you have public OnPlayerConnect and function OnPlayerConnect. Rename the function to OnPlayerConnected.
slotomic : actully its OnPlayerConnect public and i also changed it to public nothing happens
You might be having an infinite loop.
Show your ALS Hooks on OnPlayerConnect.
Add prints in random locations in your OnPlayerConnect and let us know where the last print was.
AFAIK, you can't get country on connect callback.
This loop is stupid...
Isn't that easier? Also use foreach, its way better for counting, looping and much more useful info.