#1

When I do /setadminname [ID] [ADMINNAME] It works then I do /aduty, it says I am on duty with my admin commands but my admin name does not show on the tab list or anywhere when I do /aduty again, it shuts down the server, I start it back up and my admin name appears and I have to register, why?


Aduty:

Код:
CMD:aduty(playerid, params[])
{
	new str[126];
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(GetPVarInt(playerid, "Injured") == 1) return SendClientMessage(playerid, COLOR_GREY, "You may not go on duty while injured, /giveup if emergency.");
	if(AdminDuty[playerid] != 1)
	{
	    AdminDutyCash[playerid] = PlayerInfo[playerid][pCash];
		GetPlayerHealth(playerid, AdminDutyHealth[playerid]);
	    AdminDutyArmor[playerid] = PlayerInfo[playerid][pArmor];
	    if(isnull(PlayerInfo[playerid][pAName])) return SendClientMessage(playerid, -1, "You don't have an admin name.");
		AdminDuty[playerid] = 1;
		format(str, sizeof(str), "%s (ID %i - %s) is now on duty as a level %i admin.", PlayerInfo[playerid][pAName], playerid, GetNameEx(playerid), PlayerInfo[playerid][pAdmin]);
		SendClientMessageToAdmins(-1, str, 1);
		SetPlayerName(playerid, PlayerInfo[playerid][pAName]);
		SendClientMessage(playerid, -1, "You are now on duty as an admin, you do now have access to all of your commands.");
		GetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
	}
	else
	{
	    waitcheck[playerid] = 2;
	    SetPVarInt(playerid, "SpecOff", 1);
		TogglePlayerSpectating(playerid, false);
		SetCameraBehindPlayer(playerid);
	    AdminDuty[playerid] = 0;
        SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ], 0, 0, 0, 0, 0, 0, 0);
        SpawnPlayer(playerid);
        SetPlayerWeapons(playerid);
        //SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
        //SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
		SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
		SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
		SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
	    SetPlayerName(playerid, PlayerInfo[playerid][pName1]);
		new backup[126];
		format(backup, 126, "%s Old cash: %i - New cash: %i", GetNameEx(playerid), PlayerInfo[playerid][pCash], AdminDutyCash[playerid]);
		Log("/logs/backup.txt", backup);
	    PlayerInfo[playerid][pCash] = AdminDutyCash[playerid];
	    SetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
	    format(str, sizeof(str), "%s (ID %i - %s) is now off admin duty.", PlayerInfo[playerid][pAName], playerid, GetNameEx(playerid));
		SendClientMessageToAdmins(COLOR_YELLOW, str, 1);
		SendClientMessage(playerid, -1, "You are now off duty as an admin and have only a limited access to your commands.");
		//spec[playerid] = -1;
		SetPlayerWeaponsEx(playerid);
	}
	return 1;
}
Setadminname
Код:
CMD:setadminname(playerid, params[])
{
	new giveplayerid, name[56], str[126];
	if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "us[56]", giveplayerid, name)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /setadminname [playerid/partofname] [name]");
    if(PlayerInfo[giveplayerid][pAdmin] < 1)
	{
		SendClientMessage(playerid, COLOR_WHITE, "The player is not an admin.");
		return 1;
	}

	new length = strlen(name);
	if(length < 3 || length > 20)
	{
		SendClientMessage(playerid, COLOR_WHITE, "The name can't less than 3 characters or more than 20 characters.");
		return 1;
	}

	if(strfind(name, "_", true) != -1)
	{
		SendClientMessage(playerid, COLOR_WHITE, "The admin name must be one name. There can't be an underscore in the name.");
		return 1;
	}
	format(str, 126, "AdmCmd: %s has set %s's admin-name to %s.", GetNameEx(playerid), GetNameEx(giveplayerid), name);
	SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
	format(PlayerInfo[giveplayerid][pAName], 56, name);
	return 1;
}
Reply
#2

Anyone?
Reply
#3

Does crashdetect show anything in the logs?
Reply
#4

Nope.
Reply
#5

try to change this
Код:
CMD:aduty(playerid, params[])
{
	new str[126];
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(GetPVarInt(playerid, "Injured") == 1) return SendClientMessage(playerid, COLOR_GREY, "You may not go on duty while injured, /giveup if emergency.");
	if(AdminDuty[playerid] == 0)
	{
	    AdminDutyCash[playerid] = PlayerInfo[playerid][pCash];
		GetPlayerHealth(playerid, AdminDutyHealth[playerid]);
	    AdminDutyArmor[playerid] = PlayerInfo[playerid][pArmor];
	    if(isnull(PlayerInfo[playerid][pAName])) return SendClientMessage(playerid, -1, "You don't have an admin name.");
		AdminDuty[playerid] = 1;
		format(str, sizeof(str), "%s (ID %i - %s) is now on duty as a level %i admin.", PlayerInfo[playerid][pAName], playerid, GetNameEx(playerid), PlayerInfo[playerid][pAdmin]);
		SendClientMessageToAdmins(-1, str, 1);
		SetPlayerName(playerid, PlayerInfo[playerid][pAName]);
		SendClientMessage(playerid, -1, "You are now on duty as an admin, you do now have access to all of your commands.");
		GetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
	}
	else
	{
	    waitcheck[playerid] = 2;
	    SetPVarInt(playerid, "SpecOff", 1);
		TogglePlayerSpectating(playerid, false);
		SetCameraBehindPlayer(playerid);
	    AdminDuty[playerid] = 0;
        SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ], 0, 0, 0, 0, 0, 0, 0);
        SpawnPlayer(playerid);
        SetPlayerWeapons(playerid);
        //SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
        //SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
		SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
		SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
		SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
	    SetPlayerName(playerid, PlayerInfo[playerid][pName1]);
		new backup[126];
		format(backup, 126, "%s Old cash: %i - New cash: %i", GetNameEx(playerid), PlayerInfo[playerid][pCash], AdminDutyCash[playerid]);
		Log("/logs/backup.txt", backup);
	    PlayerInfo[playerid][pCash] = AdminDutyCash[playerid];
	    SetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
	    format(str, sizeof(str), "%s (ID %i - %s) is now off admin duty.", PlayerInfo[playerid][pAName], playerid, GetNameEx(playerid));
		SendClientMessageToAdmins(COLOR_YELLOW, str, 1);
		SendClientMessage(playerid, -1, "You are now off duty as an admin and have only a limited access to your commands.");
		//spec[playerid] = -1;
		SetPlayerWeaponsEx(playerid);
	}
	return 1;
}
Reply
#6

Two reason would crash the server:

- Setting an empty name (you do check though with isnull so it is not that).
- Invalid file handle which used in Log function.

Crashdetect will print results for server crashes caused by natives so are you sure it's loaded?
Reply
#7

Have you got like Skype or Teamviewer you can help me over with, please?
Reply
#8

I put in Crashdetect and this is picked up:

Quote:

[16:11:00] [debug] Server crashed while executing prp.amx
[16:11:00] [debug] AMX backtrace:
[16:11:00] [debug] #0 native SetPlayerName () from sscanf.DLL
[16:11:00] [debug] #1 00049074 in public cmd_aduty (0, 18467452) from prp.amx
[16:11:00] [debug] #2 native CallLocalFunction () from samp-server.exe
[16:11:00] [debug] #3 00038760 in public OnPlayerCommandText (0, 18467424) from prp.amx
[16:11:01] [debug] Native backtrace:
[16:11:01] [debug] #0 00468f04 in ?? () from samp-server.exe
[16:11:01] [debug] #1 10007049 in ?? () from plugins\sscanf.DLL
[16:11:01] [debug] #2 004010b6 in ?? () from samp-server.exe
[16:11:01] [debug] #3 711c62ca in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #4 711c8b28 in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #5 711c09c7 in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #6 711c631a in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #7 711551a7 in ?? () from plugins\streamer.DLL
[16:11:01] [debug] #8 0047441e in ?? () from samp-server.exe
[16:11:01] [debug] #9 004010b6 in ?? () from samp-server.exe
[16:11:01] [debug] #10 711c62ca in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #11 711c8b28 in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #12 711c09c7 in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #13 711c631a in ?? () from plugins\crashdetect.DLL
[16:11:01] [debug] #14 711551a7 in ?? () from plugins\streamer.DLL
[16:11:01] [debug] #15 0046dbc0 in ?? () from samp-server.exe
[16:11:01] [debug] #16 004528f0 in ?? () from samp-server.exe
[16:11:01] [debug] #17 0046e780 in ?? () from samp-server.exe
[16:11:01] [debug] #18 0049d629 in ?? () from samp-server.exe
[16:11:01] [debug] #19 0045b3aa in ?? () from samp-server.exe
[16:11:01] [debug] #20 75ab14ab in ?? () from C:\Windows\syswow64\KERNELBASE.dll
[16:11:01] [debug] #21 75ab14de in ?? () from C:\Windows\syswow64\KERNELBASE.dll

Reply
#9

Oh, I missed that part.

When an admin goes on duty, you check if the name is null and you return an error if it is.
However, when an admins goes off duty, you do NOT check if the name is null and return an error if it is but you set the empty name.
Reply
#10

What do you mean? Could you do it for me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)