SA-MP Forums Archive
/freeze closes server? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /freeze closes server? (/showthread.php?tid=570140)



/freeze closes server? - izeatfishz - 05.04.2015

My /freeze command works, but it closes the server? but other cmds work fine..

Код:
CMD:freeze(playerid, params[])
{
	new string[128], targetid, tname[MAX_PLAYER_NAME+1], pname[MAX_PLAYER_NAME+1];
	if(pInfo[playerid][Admin] == 0) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!");
	
	GetPlayerName(playerid, pname, sizeof(pname)), GetPlayerName(targetid, tname, sizeof(tname));
	
	TogglePlayerControllable(targetid, 0);
	
	format(string, sizeof(string), " You have frozen %s.", pname);
	SendClientMessage(playerid, COLOR_GREY, string);
	
	format(string, sizeof(string), " Administrator %s has freezed you.", tname);
	SendClientMessage(targetid, COLOR_GREY, string);
	
	return 1;
}



Re: /freeze closes server? - ATGOggy - 05.04.2015

Use sscanf.

PHP код:
CMD:freeze(playerid, params[])
{
    new 
string[128], targetid, tname[MAX_PLAYER_NAME+1], pname[MAX_PLAYER_NAME+1];
    if(
pInfo[playerid][Admin] == 0) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!");
    if(
sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "ERROR: Correct usage: /freeze [id/name]");
    
GetPlayerName(playerid, pname, sizeof(pname)), GetPlayerName(targetid, tname, sizeof(tname));
    
    
TogglePlayerControllable(targetid, 0);
    
    
format(string, sizeof(string), " You have frozen %s.", pname);
    
SendClientMessage(playerid, COLOR_GREY, string);
    
    
format(string, sizeof(string), " Administrator %s has freezed you.", tname);
    
SendClientMessage(targetid, COLOR_GREY, string);
    
    return 
1;
} 
If it didn't fix, use crashdetect.dll and post the log made by it.


Re: /freeze closes server? - izeatfishz - 05.04.2015

+rep for you sir.


Re: /freeze closes server? - arlindi - 05.04.2015

PHP код:
CMD:freeze(playerid, params[])
{
    new 
string[128], targetid, tname[MAX_PLAYER_NAME+1], pname[MAX_PLAYER_NAME+1];
    if(
pInfo[playerid][Admin] == 0) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!");
    {
        if(
sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /freeze [id] ");//tell sscanf again if the parameters/syntax is wrong to return a special message
        
GetPlayerName(playerid, pname, sizeof(pname)), GetPlayerName(targetid, tname, sizeof(tname));    
        
TogglePlayerControllable(targetid, 0);    
        
format(string, sizeof(string), " You have frozen %s.", pname);
        
SendClientMessage(playerid, COLOR_GREY, string);    
        
format(string, sizeof(string), " Administrator %s has freezed you.", tname);
        
SendClientMessage(targetid, COLOR_GREY, string);
    }
    return 
1;
} 



Re: /freeze closes server? - izeatfishz - 05.04.2015

Quote:
Originally Posted by arlindi
Посмотреть сообщение
PHP код:
CMD:freeze(playerid, params[])
{
    new 
string[128], targetid, tname[MAX_PLAYER_NAME+1], pname[MAX_PLAYER_NAME+1];
    if(
pInfo[playerid][Admin] == 0) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!");
    {
        if(
sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /freeze [id] ");//tell sscanf again if the parameters/syntax is wrong to return a special message
        
GetPlayerName(playerid, pname, sizeof(pname)), GetPlayerName(targetid, tname, sizeof(tname));    
        
TogglePlayerControllable(targetid, 0);    
        
format(string, sizeof(string), " You have frozen %s.", pname);
        
SendClientMessage(playerid, COLOR_GREY, string);    
        
format(string, sizeof(string), " Administrator %s has freezed you.", tname);
        
SendClientMessage(targetid, COLOR_GREY, string);
    }
    return 
1;
} 
was it just the indentation?


Re: /freeze closes server? - arlindi - 05.04.2015

nOO LOOOK THE uSAGE


Re: /freeze closes server? - izeatfishz - 05.04.2015

Quote:
Originally Posted by arlindi
Посмотреть сообщение
nOO LOOOK THE uSAGE
The whole command is the same, just indented and rearranged 2 lines.


Re: /freeze closes server? - arlindi - 05.04.2015

Ok
I didnt saw the post
I was creating it for you when he post ok


Re: /freeze closes server? - izeatfishz - 05.04.2015

Quote:
Originally Posted by arlindi
Посмотреть сообщение
nOO LOOOK THE uSAGE
if so.. why does this not work?

Код:
CMD:thaw(playerid, params[])
{
    new string[128], targetid, tname[MAX_PLAYER_NAME+1], pname[MAX_PLAYER_NAME+1];
    if(pInfo[playerid][Admin] == 0) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!");
    {
	    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "ERROR: Correct usage: /thaw [id/name]");
	    GetPlayerName(playerid, pname, sizeof(pname)), GetPlayerName(targetid, tname, sizeof(tname));
		TogglePlayerControllable(targetid, 1);
		format(string, sizeof(string), " You have thawed %s.", pname);
		SendClientMessage(playerid, COLOR_GREY, string);
		format(string, sizeof(string), " %s was thawed by %s.", pname, tname);
		SendClientMessage(targetid, COLOR_GREY, " %s was thawed by %s.");
	}
	return 1;
}



Re: /freeze closes server? - arlindi - 05.04.2015

And if this not work
I do what i know
OKk