Command Freeze [+reps] [debug]
#1

Hello, my server keep crash due this reasons after debuging:
Код:
[01:21:08] [debug] Run time error 5: "Invalid memory access"
[01:21:08] [debug] AMX backtrace:
[01:21:08] [debug] #0 000199d4 in public cmd_freeze (playerid=36, params[]=@0x0019d544 "66") at C:\Users\MaHdy\Desktop\SPA Orginal Build 2\filterscripts\DAdmin6.pwn:1449
[01:21:08] [debug] #1 native CallLocalFunction () [080dcc00] from samp03svr
[01:21:08] [debug] #2 00000800 in public OnPlayerCommandText (playerid=36, cmdtext[]=@0x0019d518 "/freeze 36") at C:\Users\MaHdy\Desktop\SPA Orginal Build 2\pawno\include\ZCMD.inc:111
[01:21:10] [death] [GEC]TheCubeMaster died 255
The command freeze:
Код:
CMD:freeze(playerid,params[])
{
	if(pInfo[playerid][Admin] >= 2 || IsPlayerAdmin(playerid))
	{
		new player1 = strval(params);
		new string[256],time = strval(params);
		if(!sscanf(params,"u",player1))
		{
		    if(pInfo[player1][Freeze] == 1)return DError(playerid,"Player is already Freezed");
  			if(sscanf(params[1],"i",time))
		   	{
				if(sscanf(params[1],"c",params))
				{
					format(string,sizeof(string),"Administrator %s Has Frozen %s.Reason: Not Specified",pName(playerid),pName(player1));
				   	SendClientMessageToAll(Red,string);
				}
				else
				{
 	  				format(string,sizeof(string),"Administrator %s Has Frozen %s.Reason: %s",pName(playerid),pName(player1),params[2]);
			    	SendClientMessageToAll(Red,string);
				}
				format(string,sizeof(string),"UPDATE `Users` SET Freezed = 1,FreezeTimer = 0 WHERE Name = '%s'",pName(player1));
				mysql_query(string);
			}
			else
			{
				if(sscanf(params[1],"c",params))
				{
					format(string,sizeof(string),"Administrator %s Has Frozen %s.Reason: Not Specified.Time: %d Minutes",pName(playerid),pName(player1),time);
				   	SendClientMessageToAll(Red,string);

				}
				else
				{
	 				if(time > 9 && time < 100)
				    {
				        pInfo[player1][MuteReason] = params[4];
	 			    	format(string,sizeof(string),"Administrator %s Has Frozen %s Reason: %s.Time: %d Minutes",pName(playerid),pName(player1),params[4],time);
				    	SendClientMessageToAll(Red,string);
					}
	    			if(time > 99 && time < 1000)
				    {
					    pInfo[player1][MuteReason] = params[5];
	 			    	format(string,sizeof(string),"Administrator %s Has Frozen %s Reason: %s Time: %d Minutes",pName(playerid),pName(player1),params[5],time);
				    	SendClientMessageToAll(Red,string);
					}
					if(time > 0 && time < 10)
					{
						pInfo[player1][MuteReason] = params[3];
	 			    	format(string,sizeof(string),"Administrator %s Has Frozen %s Reason: %s Time: %d Minutes",pName(playerid),pName(player1),params[3],time);
				    	SendClientMessageToAll(Red,string);
					}
				}
				pInfo[player1][FreezeTimer] = SetTimerEx("UnFreezePlayer",time*60000,0,"d",player1);
				pInfo[player1][FreezeTimerCounter] = SetTimerEx("UnFreezeCounter",1000,1,"d",player1);
				pInfo[player1][FreezeTime] = time*60000;
				format(string,sizeof(string),"UPDATE `Users` SET Freezed = 1,FreezeTimer = %d WHERE Name = '%s'",time*60000,pName(player1));
				mysql_query(string);
			}
			TogglePlayerControllable(player1,false);
			pInfo[player1][Freeze] = 1;
			return 1;
		}
		else return DUsage(playerid,"/freeze [playerid] [time(Optional)] [reason(Optional)]");
	}
	else return LevelMSG(playerid,2);
}
What is the reason?
Reply
#2

Bump
Reply
#3

Why would you use saving right now, save the whole user under OnPlayerDisconnect instead...
Reply
#4

I believe it should be something like that:
pawn Код:
format(string,sizeof(string),"UPDATE `Users` SET `Freezed` = '1', `FreezeTimer` = '%d' WHERE `Name` = '%s'",time*60000,pName(player1));
it should work, any feedback would be appreciated.
Reply
#5

Are you sure that this is the problem? , btw i'll try
Reply
#6

its not working :/..
Reply
#7

you can also you this.
You can also change the Admin Level
PHP код:
CMD:freeze(playerid,params[])
{
    if(
PlayerInfo[playerid][Admin] >= 1)
    {
        new 
id;
        if(
sscanf(params,"u",id)) return SendClientMessage(playerid,0xFF0000AA,"USAGE: /freeze [playerid]");
        if(!
IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000AA,"ERROR: Invalid playerid");
        
TogglePlayerControllable(id,0);
        
SendClientMessage(playerid,0xFF0000AA,"( ! ) You are frozen by an Admin ! ");
    }
    return 
1;

Reply
#8

Without the line that I provided even if you fixed the other problems in your code the command won't work without my line.. Anyway I gave you already one of the solutions, why would you do the saving immediately, for example, one of the players got frozen and he got his full freezing time saved, let's assume that he finished the freezing time and if your command worked, after a crash or restart he will login again and will find himself frozen again with the full-time, in order to fix this perform the saving when disconnecting and when restarting.
Also another bad thing about this, if you don't do the saving when disconnecting you have to do the saving whenever the player does any activity and trust me that's a bad thing for a scripter and for efficiency.

So I think you need to do my first solution.
Other than that I think you are using sscanf wrongly, use "s[]" for strings like reason I think can get your code to work, but unfortunately I am on phone sorry!.

I have I helped any feedback would be appreciated!
Reply
#9

Quote:
Originally Posted by Stanford
Посмотреть сообщение
Without the line that I provided even if you fixed the other problems in your code the command won't work without my line.. Anyway I gave you already one of the solutions, why would you do the saving immediately, for example, one of the players got frozen and he got his full freezing time saved, let's assume that he finished the freezing time and if your command worked, after a crash or restart he will login again and will find himself frozen again with the full-time, in order to fix this perform the saving when disconnecting and when restarting.
Also another bad thing about this, if you don't do the saving when disconnecting you have to do the saving whenever the player does any activity and trust me that's a bad thing for a scripter and for efficiency.

So I think you need to do my first solution.
Other than that I think you are using sscanf wrongly, use "s[]" for strings like reason I think can get your code to work, but unfortunately I am on phone sorry!.

I have I helped any feedback would be appreciated!
I'd thank you for trying to help, and + rep , but the problem was with "if(!IsPlayerConnected(id))" , thank you again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)