SA-MP Forums Archive
commands with id... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: commands with id... (/showthread.php?tid=210557)



commands with id... - omer5198 - 13.01.2011

hi, i want to do a freeze command (for now, later i will do more) but i dont know how can i choose the ID
i know what i need to do (toggleplayercontrollable) but if i will do it will freeze me and not the id i choose... plz help
thx!


Re: commands with id... - Haydz - 13.01.2011

https://sampforum.blast.hk/showthread.php?tid=208304
My tut will beable to help you out.


Re: commands with id... - omer5198 - 13.01.2011

i followed you tut and this is my errors and code:
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
COMMAND:freeze(playeridparams[])
{
new 
otherplayerid;
if(
sscanf(params"d"otherplayerid)) return SendClientMessage(playeridCOLOUR_LIGHTBLUE"Use /freeze [playerid/name]");
else if(!
IsPlayerConnected(otherplayerid)) return SendClientMessage(playeridCOLOUR_GREEN"This player is not connected");
else
{
SendClientMessage(otherplayerid,COLOUR_GREEN,"The Admin %d killed you!");
TogglePlayerControllable(otherplayerid0);
}
 return 
1;}
return 
0;

errors:

PHP код:
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(20) : error 017undefined symbol "freeze"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(23) : error 017undefined symbol "sscanf"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(30) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(31) : warning 225unreachable code
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(20) : warning 203symbol is never used"COMMAND"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
2 Errors




Re: commands with id... - [SU]Balli - 13.01.2011

So first that won't work at all, it'd crash your server due to :


pawn Код:
SendClientMessage(otherplayerid,COLOUR_GREEN,"The Admin %d killed you!");
2th. Get Sscanf, and "ZCMD" includes. Or use strcmp.

//P.S @ Hayden, you didn't explain everything in your tut.

Код:
//Put this under "OnPlayerCommandText
if(strcmp(cmd, "/freeze", true) == 0) // Freezes the player. Prevents him from moving
	{
		new reason[128];
		
		
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "USAGE: /freeze [playername/id] [reason]");
				SendClientMessage(playerid, ORANGE, "FUNCTION: Will freeze the specified player.");
				return 1;
			}

			new giveplayerid = ReturnUser(tmp);
			if(giveplayerid != INVALID_PLAYER_ID)
			{
			    GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
				GetPlayerName(playerid, sendername, sizeof(sendername));
				reason = bigstrtok(cmdtext, idx);
				if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /freeze [playername/id] [reason]");
				format(string, sizeof(string), " Administrator %s froze %s. [Reason: %s ] ", sendername, giveplayername, reason);
	   			SendClientMessageToAll(red, string);
				TogglePlayerControllable(giveplayerid, false);
			}
			else if(giveplayerid == INVALID_PLAYER_ID)
			{
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, RED, string);
			}
			return 1;
	}
Put this whats below here down your script, outside any Callback.

Код:
stock strtok(const string[], &idx)
{
    new length = strlen(string);
	while ((idx < length) && (string[idx] <= ' '))
	{
		idx++;
	}
	new offset = idx;
	new result[128];
	while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
	{
		result[idx - offset] = string[idx];
		idx++;
	}
	result[idx - offset] = EOS;
	return result;
}
With this the same, put it under / above stock strtok.

Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
	new pos = 0;
	while (text[pos] < 0x21)
	{
		if (text[pos] == 0) return INVALID_PLAYER_ID;
		pos++;
	}
	new userid = INVALID_PLAYER_ID;
	if (IsNumeric(text[pos]))
	{
		userid = strval(text[pos]);
		if (userid >=0 && userid < MAX_PLAYERS)
		{
			if(!IsPlayerConnected(userid))
				userid = INVALID_PLAYER_ID;
			else return userid;
		}
	}
	new len = strlen(text[pos]);
	new count = 0;
	new pname[MAX_PLAYER_NAME];
	for (new i = 0; i < MAX_PLAYERS; i++)
	{
		if (IsPlayerConnected(i))
		{
			GetPlayerName(i, pname, sizeof (pname));
			if (strcmp(pname, text[pos], true, len) == 0)
			{
				if (len == strlen(pname)) return i;
				else
				{
					count++;
					userid = i;
				}
			}
		}
	}
	if (count != 1)
	{
		if (playerid != INVALID_PLAYER_ID)
		{
			if (count) SendClientMessage(playerid, YELLOW, "There are multiple users, enter full playername.");
			else SendClientMessage(playerid, RED, "Playername not found.");
		}
		userid = INVALID_PLAYER_ID;
	}
	return userid;
}
And the unfreeze command:

Код:
if(strcmp(cmd, "/unfreeze", true) == 0) // Unfreezes the player
	{
		 // if IsPlayerAdmin(playerid))  
	                  //{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "USAGE: /unfreeze [playername/id]");
				SendClientMessage(playerid, ORANGE, "FUNCTION: Will unfreeze the specified player.");
				return 1;
			}

			new giveplayerid = ReturnUser(tmp);
			if(giveplayerid != INVALID_PLAYER_ID)
			{
			    GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
				GetPlayerName(playerid, sendername, sizeof(sendername));
				format(string, sizeof(string), " Administrator %s has unfrozen %s ", sendername,giveplayername);
				MessageToAdmins(blue, string);
				TogglePlayerControllable(giveplayerid, true);
			}
			else if(giveplayerid == INVALID_PLAYER_ID)
			{
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, RED, string);
			}
				return 1;
	}
//Credits to Seif for that cmds.


Re: commands with id... - omer5198 - 13.01.2011

still doesn't work... code:
PHP код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define COLOUR_GREEN           0x33AA33AA
#define COLOUR_RED             0xAA3333AA
#define COLOUR_YELLOW          0xFFFF00AA
#define COLOUR_LIGHTBLUE       0x33CCFFAA
#define COLOUR_ORANGE          0xFF9900AA
public OnFilterScriptInit()
{
     print(
"\n****************************************");
    print(
"* AdminCmds *");
    print(
"****************************************\n");
     return 
1;
}
#endif
public OnPlayerCommandText(playeridcmdtext[])
{
if(
strcmp(cmd"/freeze"true) == 0// Freezes the player. Prevents him from moving
    
{
        new 
reason[128];
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /freeze [playername/id] [reason]");
                
SendClientMessage(playeridCOLOUR_ORANGE"FUNCTION: Will freeze the specified player.");
                return 
1;
            }
            new 
giveplayerid ReturnUser(tmp);
            if(
giveplayerid != INVALID_PLAYER_ID)
            {
                
GetPlayerName(giveplayeridgiveplayernamesizeof(giveplayername));
                
GetPlayerName(playeridsendernamesizeof(sendername));
                
reason bigstrtok(cmdtextidx);
                if(!
strlen(reason)) return SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /freeze [playername/id] [reason]");
                
format(stringsizeof(string), " Administrator %s froze %s. [Reason: %s ] "sendernamegiveplayernamereason);
                   
SendClientMessageToAll(redstring);
                
TogglePlayerControllable(giveplayeridfalse);
            }
            else if(
giveplayerid == INVALID_PLAYER_ID)
            {
                
format(stringsizeof(string), "%d is not an active player."giveplayerid);
                
SendClientMessage(playeridCOLOUR_REDstring);
            }
            return 
1;
    }
return 
0;
}
stock strtok(const string[], &idx)
{
    new 
length strlen(string);
    while ((
idx length) && (string[idx] <= ' '))
    {
        
idx++;
    }
    new 
offset idx;
    new 
result[128];
    while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
    {
        
result[idx offset] = string[idx];
        
idx++;
    }
    
result[idx offset] = EOS;
    return 
result;
}
ReturnUser(text[], playerid INVALID_PLAYER_ID)
{
    new 
pos 0;
    while (
text[pos] < 0x21)
    {
        if (
text[pos] == 0) return INVALID_PLAYER_ID;
        
pos++;
    }
    new 
userid INVALID_PLAYER_ID;
    if (
IsNumeric(text[pos]))
    {
        
userid strval(text[pos]);
        if (
userid >=&& userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
                
userid INVALID_PLAYER_ID;
            else return 
userid;
        }
    }
    new 
len strlen(text[pos]);
    new 
count 0;
    new 
pname[MAX_PLAYER_NAME];
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
GetPlayerName(ipnamesizeof (pname));
            if (
strcmp(pnametext[pos], truelen) == 0)
            {
                if (
len == strlen(pname)) return i;
                else
                {
                    
count++;
                    
userid i;
                }
            }
        }
    }
    if (
count != 1)
    {
        if (
playerid != INVALID_PLAYER_ID)
        {
            if (
countSendClientMessage(playeridYELLOW"There are multiple users, enter full playername.");
            else 
SendClientMessage(playeridRED"Playername not found.");
        }
        
userid INVALID_PLAYER_ID;
    }
    return 
userid;

errors:
PHP код:
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(20) : error 017undefined symbol "cmd"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(25) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(25) : error 017undefined symbol "tmp"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(25) : error 017undefined symbol "idx"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(26) : error 017undefined symbol "tmp"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(33) : error 017undefined symbol "tmp"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(36) : error 017undefined symbol "giveplayername"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(36) : error 017undefined symbol "giveplayername"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(36) : error 029invalid expressionassumed zero
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(36) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
9 Errors




Re: commands with id... - Toreno - 13.01.2011

lol, UNBELIVEABLE........ MAKE a var.
pawn Код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT

#define COLOUR_GREEN           0x33AA33AA
#define COLOUR_RED             0xAA3333AA
#define COLOUR_YELLOW          0xFFFF00AA
#define COLOUR_LIGHTBLUE       0x33CCFFAA
#define COLOUR_ORANGE          0xFF9900AA
public OnFilterScriptInit()
{
     print("\n****************************************");
    print("* AdminCmds *");
    print("****************************************\n");
     return 1;
}
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
new giveplayername[MAX_PLAYER_NAME], giveplayerid, tmp[256], cmd[256], idx;
if(strcmp(cmd, "/freeze", true) == 0) // Freezes the player. Prevents him from moving
    {
        new reason[128];


            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /freeze [playername/id] [reason]");
                SendClientMessage(playerid, COLOUR_ORANGE, "FUNCTION: Will freeze the specified player.");
                return 1;
            }

            giveplayerid = ReturnUser(tmp);
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                reason = bigstrtok(cmdtext, idx);
                if(!strlen(reason)) return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /freeze [playername/id] [reason]");
                format(string, sizeof(string), " Administrator %s froze %s. [Reason: %s ] ", sendername, giveplayername, reason);
                   SendClientMessageToAll(red, string);
                TogglePlayerControllable(giveplayerid, false);
            }
            else if(giveplayerid == INVALID_PLAYER_ID)
            {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOUR_RED, string);
            }
            return 1;
    }
return 0;
}
stock strtok(const string[], &idx)
{
    new length = strlen(string);
    while ((idx < length) && (string[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = string[idx];
        idx++;
    }
    result[idx - offset] = EOS;
    return result;
}

ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21)
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
                userid = INVALID_PLAYER_ID;
            else return userid;
        }
    }
    new len = strlen(text[pos]);
    new count = 0;
    new pname[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, YELLOW, "There are multiple users, enter full playername.");
            else SendClientMessage(playerid, RED, "Playername not found.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}



Re: commands with id... - [SU]Balli - 13.01.2011

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
lol, UNBELIVEABLE........ MAKE a var.
pawn Код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT

#define COLOUR_GREEN           0x33AA33AA
#define COLOUR_RED             0xAA3333AA
#define COLOUR_YELLOW          0xFFFF00AA
#define COLOUR_LIGHTBLUE       0x33CCFFAA
#define COLOUR_ORANGE          0xFF9900AA
public OnFilterScriptInit()
{
     print("\n****************************************");
    print("* AdminCmds *");
    print("****************************************\n");
     return 1;
}
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
new giveplayername[MAX_PLAYER_NAME], giveplayerid, tmp[256], cmd[256], idx;
if(strcmp(cmd, "/freeze", true) == 0) // Freezes the player. Prevents him from moving
    {
        new reason[128];


            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /freeze [playername/id] [reason]");
                SendClientMessage(playerid, COLOUR_ORANGE, "FUNCTION: Will freeze the specified player.");
                return 1;
            }

            giveplayerid = ReturnUser(tmp);
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                reason = bigstrtok(cmdtext, idx);
                if(!strlen(reason)) return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /freeze [playername/id] [reason]");
                format(string, sizeof(string), " Administrator %s froze %s. [Reason: %s ] ", sendername, giveplayername, reason);
                   SendClientMessageToAll(red, string);
                TogglePlayerControllable(giveplayerid, false);
            }
            else if(giveplayerid == INVALID_PLAYER_ID)
            {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOUR_RED, string);
            }
            return 1;
    }
return 0;
}
stock strtok(const string[], &idx)
{
    new length = strlen(string);
    while ((idx < length) && (string[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = string[idx];
        idx++;
    }
    result[idx - offset] = EOS;
    return result;
}

ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21)
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
                userid = INVALID_PLAYER_ID;
            else return userid;
        }
    }
    new len = strlen(text[pos]);
    new count = 0;
    new pname[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, YELLOW, "There are multiple users, enter full playername.");
            else SendClientMessage(playerid, RED, "Playername not found.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
^this.

Oh Also, before u come back and say error: undefined symbol : red , define it on top. Or change the colours to the ones you got.


Re: commands with id... - omer5198 - 13.01.2011

stil!!! it doesn't work!
code:
PHP код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define COLOUR_GREEN           0x33AA33AA
#define COLOUR_RED             0xAA3333AA
#define COLOUR_YELLOW          0xFFFF00AA
#define COLOUR_LIGHTBLUE       0x33CCFFAA
#define COLOUR_ORANGE          0xFF9900AA
public OnFilterScriptInit()
{
     print(
"\n****************************************");
    print(
"* AdminCmds *");
    print(
"****************************************\n");
     return 
1;
}
#endif
public OnPlayerCommandText(playeridcmdtext[])
{
new 
giveplayername[MAX_PLAYER_NAME], giveplayeridtmp[256], cmd[256], idx;
if(
strcmp(cmd"/freeze"true) == 0// Freezes the player. Prevents him from moving
    
{
        new 
reason[128];
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /freeze [playername/id] [reason]");
                
SendClientMessage(playeridCOLOUR_ORANGE"FUNCTION: Will freeze the specified player.");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            if(
giveplayerid != INVALID_PLAYER_ID)
            {
                
GetPlayerName(giveplayeridgiveplayernamesizeof(giveplayername));
                
GetPlayerName(playeridsendernamesizeof(sendername));
                
reason bigstrtok(cmdtextidx);
                if(!
strlen(reason)) return SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /freeze [playername/id] [reason]");
                
format(stringsizeof(string), " Administrator %s froze %s. [Reason: %s ] "sendernamegiveplayernamereason);
                   
SendClientMessageToAll(redstring);
                
TogglePlayerControllable(giveplayeridfalse);
            }
            else if(
giveplayerid == INVALID_PLAYER_ID)
            {
                
format(stringsizeof(string), "%d is not an active player."giveplayerid);
                
SendClientMessage(playeridCOLOUR_REDstring);
            }
            return 
1;
    }
return 
0;
}
stock strtok(const string[], &idx)
{
    new 
length strlen(string);
    while ((
idx length) && (string[idx] <= ' '))
    {
        
idx++;
    }
    new 
offset idx;
    new 
result[128];
    while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
    {
        
result[idx offset] = string[idx];
        
idx++;
    }
    
result[idx offset] = EOS;
    return 
result;
}
ReturnUser(text[], playerid INVALID_PLAYER_ID)
{
    new 
pos 0;
    while (
text[pos] < 0x21)
    {
        if (
text[pos] == 0) return INVALID_PLAYER_ID;
        
pos++;
    }
    new 
userid INVALID_PLAYER_ID;
    if (
IsNumeric(text[pos]))
    {
        
userid strval(text[pos]);
        if (
userid >=&& userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
                
userid INVALID_PLAYER_ID;
            else return 
userid;
        }
    }
    new 
len strlen(text[pos]);
    new 
count 0;
    new 
pname[MAX_PLAYER_NAME];
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
GetPlayerName(ipnamesizeof (pname));
            if (
strcmp(pnametext[pos], truelen) == 0)
            {
                if (
len == strlen(pname)) return i;
                else
                {
                    
count++;
                    
userid i;
                }
            }
        }
    }
    if (
count != 1)
    {
        if (
playerid != INVALID_PLAYER_ID)
        {
            if (
countSendClientMessage(playeridYELLOW"There are multiple users, enter full playername.");
            else 
SendClientMessage(playeridRED"Playername not found.");
        }
        
userid INVALID_PLAYER_ID;
    }
    return 
userid;

errors:
PHP код:
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(13) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(15) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(26) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(38) : error 017undefined symbol "sendername"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(38) : error 017undefined symbol "sendername"
D:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(38) : error 029invalid expressionassumed zero
D
:\gta san andreas online\Godfucker\filterscripts\AdminCmds.pwn(38) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors




Re: commands with id... - alpha500delta - 13.01.2011

Do you have any scripting knowledge AT ALL?

#pragma tabsize 0 for the loose indentation

new sendername[24 or idk] << Delete the "idk" ofcourse >.>

Try to edit some code yourself, and look at the SA:MP Wiki.


Re: commands with id... - [SU]Balli - 13.01.2011

PHP код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define COLOUR_GREEN           0x33AA33AA
#define COLOUR_RED             0xAA3333AA
#define COLOUR_YELLOW          0xFFFF00AA
#define COLOUR_LIGHTBLUE       0x33CCFFAA
#define COLOUR_ORANGE          0xFF9900AA
public OnFilterScriptInit()
{
     print(
"\n****************************************");
    print(
"* AdminCmds *");
    print(
"****************************************\n");
     return 
1;
}
#endif
public OnPlayerCommandText(playeridcmdtext[])
{
new 
giveplayername[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], giveplayeridtmp[256], cmd[256], idx;
if(
strcmp(cmd"/freeze"true) == 0// Freezes the player. Prevents him from moving
    
{
        new 
reason[128];
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /freeze [playername/id] [reason]");
                
SendClientMessage(playeridCOLOUR_ORANGE"FUNCTION: Will freeze the specified player.");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            if(
giveplayerid != INVALID_PLAYER_ID)
            {
                
GetPlayerName(giveplayeridgiveplayernamesizeof(giveplayername));
                
GetPlayerName(playeridsendernamesizeof(sendername));
                
reason bigstrtok(cmdtextidx);
                if(!
strlen(reason)) return SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /freeze [playername/id] [reason]");
                
format(stringsizeof(string), " Administrator %s froze %s. [Reason: %s ] "sendernamegiveplayernamereason);
                   
SendClientMessageToAll(redstring);
                
TogglePlayerControllable(giveplayeridfalse);
            }
            else if(
giveplayerid == INVALID_PLAYER_ID)
            {
                
format(stringsizeof(string), "%d is not an active player."giveplayerid);
                
SendClientMessage(playeridCOLOUR_REDstring);
            }
            return 
1;
    }
return 
0;
}
stock strtok(const string[], &idx)
{
    new 
length strlen(string);
    while ((
idx length) && (string[idx] <= ' '))
    {
        
idx++;
    }
    new 
offset idx;
    new 
result[128];
    while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
    {
        
result[idx offset] = string[idx];
        
idx++;
    }
    
result[idx offset] = EOS;
    return 
result;
}
ReturnUser(text[], playerid INVALID_PLAYER_ID)
{
    new 
pos 0;
    while (
text[pos] < 0x21)
    {
        if (
text[pos] == 0) return INVALID_PLAYER_ID;
        
pos++;
    }
    new 
userid INVALID_PLAYER_ID;
    if (
IsNumeric(text[pos]))
    {
        
userid strval(text[pos]);
        if (
userid >=&& userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
                
userid INVALID_PLAYER_ID;
            else return 
userid;
        }
    }
    new 
len strlen(text[pos]);
    new 
count 0;
    new 
pname[MAX_PLAYER_NAME];
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
GetPlayerName(ipnamesizeof (pname));
            if (
strcmp(pnametext[pos], truelen) == 0)
            {
                if (
len == strlen(pname)) return i;
                else
                {
                    
count++;
                    
userid i;
                }
            }
        }
    }
    if (
count != 1)
    {
        if (
playerid != INVALID_PLAYER_ID)
        {
            if (
countSendClientMessage(playeridYELLOW"There are multiple users, enter full playername.");
            else 
SendClientMessage(playeridRED"Playername not found.");
        }
        
userid INVALID_PLAYER_ID;
    }
    return 
userid;