Server Crash with AFK command
#1

Hi everybody i have created a command /afk but when i use it in game the server crash there is the code :

Код:
COMMAND:afk(playerid, params[])
{
	// Send the command to all admins so they can see it
	SendAdminText(playerid, "/afk", params);

	// Exit the command if the player hasn't logged in using his password
	if (APlayerData[playerid][LoggedIn] == false) return 0;
	new Name[24], string[128], AFKName[25];
	TogglePlayerControllable(playerid,0);
	GetPlayerName(playerid, Name, sizeof(Name));
    GetPlayerName(playerid, AFKName, sizeof(AFKName));
 	format(string, sizeof(string),"%s(afk)", AFKName);
    SetPlayerName(0xFFFFFF, string);
	format(string, sizeof(string),"Le joueur %s c'est mis afk !", Name);
	SendClientMessageToAll(0xFFFFFF, string);
	// message afk
	SendClientMessage(playerid,0xFFFFFFFF, "Vous etes maintenant afk !");
	return 1;
}
Crash :
Код:
--------------------------

SA-MP Server: 0.3.7-R2



Exception At Address: 0x004033F9 Module: (samp-server.exe)



Registers:

EAX: 0x00000000	EBX: 0x0000000F	ECX: 0x00000074	EDX: 0x00000000

ESI: 0x05C9C468	EDI: 0x00FFFFFF	EBP: 0x1A443C18	ESP: 0x0019F32C

EFLAGS: 0x00010202



Stack:

+0000: 0x00FFFFFF   0x05C9C3F4   0x0019F360   0x029978B8

+0010: 0x10007041   0x1A443C18   0x05C9C464   0x00000000

+0020: 0x0000000F   0x029978B8   0x059060B8   0x029978B8

+0030: 0x05C9C464   0x05978ED0   0x004010B6   0x029978B8

+0040: 0x0000000E   0x059B7CCC   0x00402B63   0x029978B8

+0050: 0x00000096   0x0019F398   0x05C9C3F4   0x0019F3E4

+0060: 0x029978B8   0x0000003B   0x00000002   0x00000001

+0070: 0x002E4720   0x002E4728   0x002E4A0C   0x002E0AD8

+0080: 0x002E49F8   0x002E0AD8   0x059060B8   0x059B7CCC

+0090: 0x00000000   0x05904020   0x000B1C14   0x61224469

+00A0: 0x029978B8   0x0019F834   0x0000003B   0x05C9C6E4

+00B0: 0x00000001   0x029978B8   0x0019F844   0x004746BE

+00C0: 0x00000002   0x0019F834   0x0000003B   0x00470001

+00D0: 0x00007369   0x5F646D63   0x006B6661   0x029978B8

+00E0: 0x029978B8   0x059060B8   0x002E0AD0   0x00000000

+00F0: 0x00000000   0x00000000   0x00000000   0x00000000

+0100: 0x00000000   0x00000000   0x00000000   0x00000000

+0110: 0x00000000   0x00000000   0x00000000   0x00000000

+0120: 0x00000000   0x00000000   0x0019F470   0x76FC0AD9

+0130: 0x0019F46C   0x024B0000   0x00000009   0x00DE0000



--------------------------



Loaded Modules:

samp-server.exe	A: 0x00400000 - 0x00519000	(C:\Users\mickael\Desktop\Serveur SAMP\samp-server.exe)

ntdll.dll	A: 0x76F60000 - 0x770DB000	(C:\WINDOWS\SYSTEM32\ntdll.dll)

KERNEL32.DLL	A: 0x741A0000 - 0x74280000	(C:\WINDOWS\SYSTEM32\KERNEL32.DLL)

KERNELBASE.dll	A: 0x74440000 - 0x745BE000	(C:\WINDOWS\SYSTEM32\KERNELBASE.dll)

UMEngx86.dll	A: 0x61270000 - 0x612AE000	(C:\Program Files (x86)\Norton 360\NortonData\22.5.2.15\Definitions\BASHDefs\20160316.006\UMEngx86.dll)

SHELL32.dll	A: 0x747C0000 - 0x75BBE000	(C:\WINDOWS\SYSTEM32\SHELL32.dll)

msvcrt.dll	A: 0x74700000 - 0x747BE000	(C:\WINDOWS\SYSTEM32\msvcrt.dll)

cfgmgr32.dll	A: 0x762A0000 - 0x762D7000	(C:\WINDOWS\SYSTEM32\cfgmgr32.dll)

windows.storage.dll	A: 0x76A60000 - 0x76F5A000	(C:\WINDOWS\SYSTEM32\windows.storage.dll)

combase.dll	A: 0x767B0000 - 0x7696D000	(C:\WINDOWS\SYSTEM32\combase.dll)

RPCRT4.dll	A: 0x75BD0000 - 0x75C7D000	(C:\WINDOWS\SYSTEM32\RPCRT4.dll)

SspiCli.dll	A: 0x73C90000 - 0x73CAE000	(C:\WINDOWS\SYSTEM32\SspiCli.dll)

CRYPTBASE.dll	A: 0x73C80000 - 0x73C8A000	(C:\WINDOWS\SYSTEM32\CRYPTBASE.dll)

bcryptPrimitives.dll	A: 0x73CB0000 - 0x73D08000	(C:\WINDOWS\SYSTEM32\bcryptPrimitives.dll)

sechost.dll	A: 0x73D10000 - 0x73D54000	(C:\WINDOWS\SYSTEM32\sechost.dll)

advapi32.dll	A: 0x73E60000 - 0x73EDB000	(C:\WINDOWS\SYSTEM32\advapi32.dll)

shlwapi.dll	A: 0x76660000 - 0x766A5000	(C:\WINDOWS\SYSTEM32\shlwapi.dll)

GDI32.dll	A: 0x74040000 - 0x7418F000	(C:\WINDOWS\SYSTEM32\GDI32.dll)

USER32.dll	A: 0x762E0000 - 0x76427000	(C:\WINDOWS\SYSTEM32\USER32.dll)

kernel.appcore.dll	A: 0x73EE0000 - 0x73EEC000	(C:\WINDOWS\SYSTEM32\kernel.appcore.dll)

shcore.dll	A: 0x76530000 - 0x765BD000	(C:\WINDOWS\SYSTEM32\shcore.dll)

powrprof.dll	A: 0x73FF0000 - 0x74034000	(C:\WINDOWS\SYSTEM32\powrprof.dll)

profapi.dll	A: 0x76430000 - 0x7643F000	(C:\WINDOWS\SYSTEM32\profapi.dll)

WSOCK32.dll	A: 0x73A70000 - 0x73A78000	(C:\WINDOWS\SYSTEM32\WSOCK32.dll)

WINMM.dll	A: 0x723F0000 - 0x72414000	(C:\WINDOWS\SYSTEM32\WINMM.dll)

WS2_32.dll	A: 0x76090000 - 0x760EF000	(C:\WINDOWS\SYSTEM32\WS2_32.dll)

WINMMBASE.dll	A: 0x723C0000 - 0x723E3000	(C:\WINDOWS\SYSTEM32\WINMMBASE.dll)

IMM32.DLL	A: 0x766B0000 - 0x766DB000	(C:\WINDOWS\SYSTEM32\IMM32.DLL)

sscanf.DLL	A: 0x10000000 - 0x1000D000	(C:\Users\mickael\Desktop\Serveur SAMP\plugins\sscanf.DLL)

MSVCR100.dll	A: 0x738E0000 - 0x7399F000	(C:\WINDOWS\SYSTEM32\MSVCR100.dll)

streamer.DLL	A: 0x61220000 - 0x6126A000	(C:\Users\mickael\Desktop\Serveur SAMP\plugins\streamer.DLL)

VCRUNTIME140.dll	A: 0x61190000 - 0x611A5000	(C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll)

MSVCP140.dll	A: 0x611B0000 - 0x6121D000	(C:\WINDOWS\SYSTEM32\MSVCP140.dll)

ucrtbase.dll	A: 0x63DB0000 - 0x63E91000	(C:\WINDOWS\SYSTEM32\ucrtbase.dll)

FileManager.DLL	A: 0x6E440000 - 0x6E44B000	(C:\Users\mickael\Desktop\Serveur SAMP\plugins\FileManager.DLL)

MSVCR110.dll	A: 0x5FD40000 - 0x5FE16000	(C:\WINDOWS\SYSTEM32\MSVCR110.dll)

MSVCP110.dll	A: 0x60340000 - 0x603C5000	(C:\WINDOWS\SYSTEM32\MSVCP110.dll)

zdengine.dll	A: 0x02420000 - 0x02435000	(C:\WINDOWS\system32\zdengine.dll)

MSWSOCK.dll	A: 0x73130000 - 0x7317F000	(C:\WINDOWS\SYSTEM32\MSWSOCK.dll)

IPHLPAPI.DLL	A: 0x73A80000 - 0x73AAF000	(C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL)

OLEAUT32.dll	A: 0x765C0000 - 0x76652000	(C:\WINDOWS\SYSTEM32\OLEAUT32.dll)

VERSION.dll	A: 0x73C70000 - 0x73C78000	(C:\WINDOWS\SYSTEM32\VERSION.dll)

CRYPT32.dll	A: 0x760F0000 - 0x76268000	(C:\WINDOWS\SYSTEM32\CRYPT32.dll)

MSASN1.dll	A: 0x74190000 - 0x7419E000	(C:\WINDOWS\SYSTEM32\MSASN1.dll)

napinsp.dll	A: 0x6F340000 - 0x6F352000	(C:\WINDOWS\system32\napinsp.dll)

pnrpnsp.dll	A: 0x6F200000 - 0x6F216000	(C:\WINDOWS\system32\pnrpnsp.dll)

NLAapi.dll	A: 0x6F1E0000 - 0x6F1F4000	(C:\WINDOWS\system32\NLAapi.dll)

DNSAPI.dll	A: 0x72D00000 - 0x72D84000	(C:\WINDOWS\SYSTEM32\DNSAPI.dll)

NSI.dll	A: 0x766E0000 - 0x766E7000	(C:\WINDOWS\SYSTEM32\NSI.dll)

winrnr.dll	A: 0x706E0000 - 0x706EB000	(C:\WINDOWS\System32\winrnr.dll)

bcrypt.dll	A: 0x73BE0000 - 0x73BFB000	(C:\WINDOWS\SYSTEM32\bcrypt.dll)

rasadhlp.dll	A: 0x72CF0000 - 0x72CF8000	(C:\Windows\System32\rasadhlp.dll)

uxtheme.dll	A: 0x6FF20000 - 0x6FF95000	(C:\WINDOWS\system32\uxtheme.dll)
Reply
#2

Up, please help me
Reply
#3

The brackets () are not allowed to be used in a nickname.
Try to change:
Код HTML:
format(string, sizeof(string),"%s(afk)", AFKName);
with:
Код HTML:
format(string, sizeof(string),"%s[afk]", AFKName);
Reply
#4

i have do that this doesn't working
Reply
#5

Quote:
Originally Posted by Eymeric69
Посмотреть сообщение
i have do that this doesn't working
Also change :
SetPlayerName(0xFFFFFF, string);
to:
SetPlayerName(playerid, string);
Reply
#6

oh i have copy and pasted an another command i have forget to change that thank you
Reply
#7

Quote:
Originally Posted by Eymeric69
Посмотреть сообщение
oh i have copy and pasted an another command i have forget to change that thank you
you're welcome
Reply
#8

The code is really messed up, it makes no sense at all.
Код:
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(playerid, AFKName, sizeof(AFKName));
Why getting the player's name twice? That's completely useless.

And, SetPlayerName(0xFFFFFF, string); You are using this function in a wrong way. Proper parameters for this function is SetPlayerName(playerid, const name[], len); If you are trying to set the player's color when they go afk, use SetPlayerColor instead. (Already answered by the guy above)

That's what happens when you just copy and paste other's script without knowing yourself how does it work.
Reply
#9

PHP код:
COMMAND:afk(playeridparams[])
{
    
// Send the command to all admins so they can see it
    
SendAdminText(playerid"/afk"params);

    
// Exit the command if the player hasn't logged in using his password
    
if (APlayerData[playerid][LoggedIn] == false) return 0
With these lines, you send the admins a message, before checking if the player can use the command at all.

Anyway, are you sorted on this topic, or is it still crashing?
Reply
#10

Change зa :
PHP код:
 format(stringsizeof(string),"Le joueur %s c'est mis afk !"Name); 
par :
PHP код:
 format(stringsizeof(string),"Le joueur %s s'est mis afk !"Name); 
(Petite faute d'orthographe )

Comme l'a dit la personne au-dessus de moi, pourquoi utilises-tu 2 variables diffйrentes pour stocker le nom du joueur? Une seule suffit largement! Tu l'a dйfinis dиs le dйbut de ta commande et tu peux l'utiliser tout au long de celle ci comme bon te semble. Pas besoin de restocker le nom du joueur dans une autre variable.

Un truc m'embкte, c'est ton return 0; pourquoi? Parce que si le joueur n'est pas connectй (avec /login ou un truc du genre), un message apparaоtra : SERVER: Unknown command ou ce que tu as dйfinis dans OnPlayerCommandPerformed. Pour rectifier зa, met return 1; tout simplement.

De plus il est vrai qu'avant de copier/coller un script d'une autre personne, pense а comprendre l'intйgralitй du script.

Ah oui, derniиre chose. Quand tu veux dйfinir une variable pour un pseudo, utilise MAX_PLAYER_NAME.
Exemple :
PHP код:
 new name[MAX_PLAYER_NAME]; 
Comme зa tu es sыr que le nombre de caractиre maximum autorisй par SA:MP n'est pas dйpassй. (Max. 24)

Voilа quelques conseils. A toi de les prendre en compte ou non. Si tu as besoin d'aide ou autre, hйsite pas а me faire signe.
J'espиre t'avoir aidй.

I just gave some tips. You all guys were completely true.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)