PDA

View Full Version : Crash after login, after adding a Privilege


NBass
06/03/2017, 10:13 PM
Hello,
i have 2lvl Admin system. The first lvl Admin is functional ok, but if i give a second one to the player by the command, after reconnect the player to the server, after login, the player is getting crash.

The code to give the Admin, is fine.


if(!strcmp(cmdtext, "/giveadminsec", true,13))
{
if(playerDB[playerid][sadmin]!= true){SendClientMessage(playerid, RED, "* No command!"); return 1;}
new tname[MAX_PLAYER_NAME];
strmid(tname,GetArgument(1, cmdtext, 0),0,MAX_PLAYER_NAME);
if(!strcmp(tname,"0",true)){SendClientMessage(playerid, BLUE, "* Give Admin lvl2: /giveadminsec [nick]"); return 1;}
new tid = GetPlayeridMid(tname);
if(tid==INVALID_PLAYER_ID)
{
SendClientMessage(playerid,RED,"*No player by this name");
return 1; }
GetPlayerName(tid,tname,sizeof(tname));
new mess[256],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
playerDB[tid][adminsec] = true;
format(mess,sizeof(mess),"* Congratulations, you're the 2lvl Admin.");
SavePlayerData(tid, false);
SendClientMessage(tid,RED,mess);
format(mess,sizeof(mess),"* You gave the Second lvl admin to %s.",tname);
SendClientMessage(playerid,RED,mess);
return 1;
}


The PlayerDB, and other are just fine.

If i make myself a Admin lvl 2 in the PlayerDB to "adminsec=1", after login, i getting crash..

Toroi
06/03/2017, 10:14 PM
Post your OnPlayerConnect / OnPlayerSpawn, please.

Also, I think this variable's name is the definition of your code:

new mess[256]

NBass
06/03/2017, 10:44 PM
Here it is


public OnPlayerConnect(playerid)
{
new ConnIP[16];
GetPlayerIp(playerid,ConnIP,16);
new compare_IP[16];
new number_IP = 0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerIp(i,compare_IP,16);
if(!strcmp(compare_IP,ConnIP)) number_IP++;
}

}
if((GetTickCount() - Join_Stamp) < Time_Limit)
exceed=1;
else
exceed=0;
if(strcmp(ban_s, ConnIP, false) == 0 && exceed == 1 )
{
Same_IP++;
if(Same_IP > IP_Connect)
{
Ban(playerid);
Same_IP=0;
}
}
else
{
Same_IP=0;
}
if(number_IP > IP_LIMIT)
Kick(playerid);
GetStampIP(playerid);
return 1;
}



public OnPlayerSpawn(playerid){
playerDB[playerid][plays] = true;
TextDrawHideForPlayer(playerid,lbt);
TextDrawHideForPlayer(playerid,lbb);
PreloadAnimLib(playerid,"ON_LOOKERS");
PreloadAnimLib(playerid,"ped");
PreloadAnimLib(playerid, "BEACH");
PreloadAnimLib(playerid, "benchpress");
PreloadAnimLib(playerid, "CAR");
PreloadAnimLib(playerid, "CARRY");
PreloadAnimLib(playerid, "CAMERA");
PreloadAnimLib(playerid, "COP_AMBIENT");
PreloadAnimLib(playerid, "DODGE");
PreloadAnimLib(playerid, "POLICE");
PreloadAnimLib(playerid, "PARK");
PreloadAnimLib(playerid, "GRAVEYARD");
PreloadAnimLib(playerid, "KISSING");
PreloadAnimLib(playerid, "GANGS");
PreloadAnimLib(playerid, "DAM_JUMP");
PreloadAnimLib(playerid, "MISC");
PreloadAnimLib(playerid, "HEIST9");
PreloadAnimLib(playerid, "PAULNMAC");
PreloadAnimLib(playerid, "VENDING");
PreloadAnimLib(playerid,"SMOKING");

if(playerDB[playerid][triedlogin] == false){SendClientMessage(playerid,GREY,"* First you must login.!");Kick(playerid); return 0;}
if(playerDB[playerid][authstate]==2)
{
LoadPlayerData(playerid);
playerDB[playerid][authstate]=4;
SetPlayerColor(playerid,PLAYCOL_HIDDEN);
}else{
if(!playerDB[playerid][uniformd])
{
playerDB[playerid][skin] = GetPlayerSkin(playerid);
playerDB[playerid][gender] = GetGender(playerDB[playerid][skin]);
}
}
TextDrawShowForPlayer(playerid,TextdrawMap1);
TextDrawShowForPlayer(playerid,TextdrawMap2);
//NICK SPALVOS
if(playerDB[playerid][sadmin])//SuperAdmin spalva
{
SetPlayerColor(playerid, 0x41A317FF);
}
if(playerDB[playerid][admin])//GoldVip spalva
{
SetPlayerColor(playerid, 0xFFFF00FF);
}
if(playerDB[playerid][adminsec])//VIP spalva
{
SetPlayerColor(playerid,0xC2A2DAAA);
}

if(playerDB[playerid][newplayer]==true)
{
for(new i=0; i < MAX_PLAYERS; i++)
TogglePlayerControllable(playerid,true);

if(playerDB[playerid][gender] == 0)
{
SetPlayerSkin(playerid,216);
playerDB[playerid][skin]=216;
}
if(playerDB[playerid][gender] == 1)
{
SetPlayerSkin(playerid,2);
playerDB[playerid][skin]=2;
}
ShowPlayerDialog(playerid, 871, DIALOG_STYLE_MSGBOX,"", "{FFFFFF}Welcome to our Server", "Okey", "");
GivePlayerMoneyA(playerid,50000);
SetPlayerScore(playerid,7000);
playerDB[playerid][skin] = GetPlayerSkin(playerid);
playerDB[playerid][newplayer] = false;
SetPlayerPos(playerid, -1422.1948,-288.2932,14.1484);
SetPlayerInterior(playerid,0);

}



if(playerDB[playerid][authstate]!=2)
{
SetPlayerHealth(playerid,40+random(50));
PlayerPlaySound(playerid, 1150, 257.6206, -41.5307, 1002.0234);// Garsas
}


if(playerDB[playerid][authstate] <2)
{
SetPlayerColor(playerid,PLAYCOL_HIDDEN);
playerDB[playerid][authstate]=3;
}


if (playerDB[playerid][jailed])
{
JailPlayer(playerid,1772.6162,-1575.3723,1742.4609,0,playerDB[playerid][jail_time]*1000,0,-1611.9078,717.9592,13.1343,1.9181,0,true);
}

globC08[playerid] = 0;
return 1;
}

Toroi
06/03/2017, 10:56 PM
This may be the issue, as when the player spawns he complies with the 3 statements, the function SetPlayerColor is called twice (if not more)

if(playerDB[playerid][sadmin])//SuperAdmin spalva
{
SetPlayerColor(playerid, 0x41A317FF);
}
if(playerDB[playerid][admin])//GoldVip spalva
{
SetPlayerColor(playerid, 0xFFFF00FF);
}
if(playerDB[playerid][adminsec])//VIP spalva
{
SetPlayerColor(playerid,0xC2A2DAAA);
}

Try changing it for

if(playerDB[playerid][sadmin])//SuperAdmin spalva
{
SetPlayerColor(playerid, 0x41A317FF);
}
else if(playerDB[playerid][admin])//GoldVip spalva
{
SetPlayerColor(playerid, 0xFFFF00FF);
}
else if(playerDB[playerid][adminsec])//VIP spalva
{
SetPlayerColor(playerid,0xC2A2DAAA);
}

Apart from that, I can't see anything wrong (atleast something that could cause a crash), let me keep reading carefuly, if I find something i'll edit this message.

NBass
06/03/2017, 11:07 PM
Thank you for helping me, but it seems not working. Still Crashing.

Toroi
06/03/2017, 11:16 PM
Your code is so broken, my friend. What gamemode is it? Did you make it yourself?

What is the purpose of this loop under OnPlayerSpawn?

for(new i=0; i < MAX_PLAYERS; i++)

NBass
06/03/2017, 11:20 PM
No, it's an edit. LTG GM

Toroi
06/03/2017, 11:32 PM
That gamemode is OLD as fuck. If you're starting to code, i'd recommend you to use a newer GM, for your sake.

If you want to keep trying your actual one to work, remove the line I pointed in my previous post and test.

Also, show us your player enumerators, please.

NBass
07/03/2017, 12:24 AM
Nope, still crashing :D

Yeah, i could go on a newer GM, but i still like that :D

Can you give more details, what do you mean about player enumerator?

Thanks you, anyway

Toroi
07/03/2017, 12:40 AM
They are at the top of your gamemode and look like this:


enum data
{
admin,
adminsec,
sadmin,
..
}
new playerDB[MAX_PLAYERS][data];


We can start working from there

NBass
07/03/2017, 09:34 AM
Delete

NBass
07/03/2017, 09:41 AM
Found something on Server log via Crashdetector, maybe it means something, maybe it's comes because i'm not loeaded a xStreamer.so, while with it, server won't start and getting "Segmentation fault", so the Server Log:
[12:29:35] [join] Test_User has joined the server (**.***.***)
[12:30:21] [debug] Run time error 19: "File or function is not found"
[12:30:21] [debug] UpdateMovingObjects
[12:30:21] [debug] StreamObjects
[12:30:21] [debug] ConnectPlayer
[12:30:21] [debug] DisconnectPlayer
[12:30:21] save cars
[12:30:21] [part] Test_User has left the server (0:0)

Anyway, found only in PlayerDB:

enum item{
bool:admin,
bool:adminsec,
bool:sadmin,
....
}

new playerDB[MAX_PLAYERS][item];

Toroi
07/03/2017, 04:03 PM
Are you using linux or windows? I have never used crashdetector.

If you are using Windows you should write 'xStreamer' only in the cfg. file, and check that you have the xStreamer.dll file in the plugin folder, if you're using Linux you need to write indeed 'xStreamer.so' and check that you have the xStreamer.so file in the plugins folder. However I don't think that would cause a crash.

NBass
07/03/2017, 04:33 PM
Yes, i'm using a Linux. I know, and i tried with xStreamer.so, but it even start the server :D About the Game mode, Hmm, I'm trying to get the secondadmin work again, but it seems the code is good, commands, saving too. The Admin one is working, but why the second :D Magic...

Toroi
07/03/2017, 05:09 PM
CTRL + F in your gamemode and look for
if(playerDB[playerid][adminsec]

Check if there's anything wrong on there, may be under OnPlayerUpdate or something as you're getting kicked instantly.