SA-MP Forums Archive
Offline commands problem - 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: Offline commands problem (/showthread.php?tid=410596)



Offline commands problem - |MadDog| - 26.01.2013

I made offline command and don't work:

Код:
CMD:off(playerid, params[])
	{
	    new text[128]; new player; new ammount; new string[128];
	    if(sscanf(params, "us[48]i", player, text, ammount))
		{
			SendClientMessage(playerid, WHITE, "HELP: /off [Player_Player] [admin/leader] [ammount]");
			SendClientMessage(playerid, WHITE, "HELP: admin | leader");
			return 1;
		}
		if(strcmp(text,"admin",true) == 0)
		{
		format(string, sizeof(string),"Players/%s.ini", player);
		dini_IntSet(string,"Admin",ammount);
		format(string,sizeof(string),"You set admin: %s level: %d", player, ammount);
		SendClientMessage(playerid, RED, string);
		}
		if(strcmp(text,"leader",true) == 0)
		{
		format(string, sizeof(string),"Players/%s.ini", player);
		dini_IntSet(string,"Leader",ammount);
		format(string,sizeof(string),"You set: %s to run gang ID: %d", player, ammount);
		SendClientMessage(playerid, RED, string);
		}
		return 1;
	}
Can u tell me whats wrong?

Sry for my bad English.


Re: Offline commands problem - Threshold - 26.01.2013

if(sscanf(params, "us[48]i", player, text, ammount))

The sscanf parameter 'u' will search through ONLINE players, not offline. You need to change this to a string ('s'), and check if a file with their name exists, otherwise return an error message...


Re: Offline commands problem - |MadDog| - 26.01.2013

How to change parameter "u" to search offline player? I'm not good with sscanf :S


Re: Offline commands problem - Frede - 26.01.2013

Quote:
Originally Posted by |MadDog|
Посмотреть сообщение
How to change parameter "u" to search offline player? I'm not good with sscanf :S
Then use strtok


Re: Offline commands problem - Threshold - 26.01.2013

"You need to change this to a string ('s')"

so it will look like this:
pawn Код:
CMD:off(playerid, params[])
{
    new text[8], player[MAX_PLAYER_NAME], ammount;
    if(sscanf(params, "s[24]s[8]i", player, text, ammount))
    {
        SendClientMessage(playerid, WHITE, "HELP: /off [Player_Player] [admin/leader] [ammount]");
        SendClientMessage(playerid, WHITE, "HELP: admin | leader");
        return 1;
    }
    new string[128];
    if(strcmp(text,"admin",true) == 0)
    {
        format(string, sizeof(string),"Players/%s.ini", player);
        if(!fexist(string)) return SendClientMessage(playerid, RED, "This player does not exist.");
        dini_IntSet(string,"Admin",ammount);
        format(string,sizeof(string),"You set admin: %s level: %d", player, ammount);
        SendClientMessage(playerid, 0xFFFF00FF, string);
    }
    else if(strcmp(text,"leader",true) == 0)
    {
        format(string, sizeof(string),"Players/%s.ini", player);
        if(!fexist(string)) return SendClientMessage(playerid, RED, "This player does not exist.");
        dini_IntSet(string,"Leader",ammount);
        format(string,sizeof(string),"You set: %s to run gang ID: %d", player, ammount);
        SendClientMessage(playerid, 0xFFFF00FF, string);
    }
    else
    {
        SendClientMessage(playerid, WHITE, "HELP: /off [Player_Player] [admin/leader] [ammount]");
        SendClientMessage(playerid, WHITE, "HELP: admin | leader");
    }
    return 1;
}
Hope this works for you.


Re: Offline commands problem - |MadDog| - 26.01.2013

Thanks bro!!

Rep +