Crash after login, after adding a Privilege
#1

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.

Код HTML:
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..
Reply
#2

Post your OnPlayerConnect / OnPlayerSpawn, please.

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

Код:
new mess[256]
Reply
#3

Here it is

Quote:

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;
}

Quote:

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;
}

Reply
#4

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.
Reply
#5

Thank you for helping me, but it seems not working. Still Crashing.
Reply
#6

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++)
Reply
#7

No, it's an edit. LTG GM
Reply
#8

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.
Reply
#9

Nope, still crashing

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

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

Thanks you, anyway
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)