Added streamer plugin, no commands work.
#1

So I added sscanf plugin and inc,
but now when I am ingame, the commands don't work.
this is my script
Код:
#include <a_samp>
#include <foreach>
#include <YSI\y_ini>
#include <zcmd>
#include <sscanf2>

//Colors
#define	COLOR_BLACK		"{000000}"
#define	COLOR_WHITE		"{FFFFFF}"
#define	COLOR_GREEN		"{00FF00}"
#define	COLOR_RED		"{FF0000}"
#define	COLOR_BLUE		"{0000FF}"
#define	COLOR_YELLOW	"{FFFF00}"
#define	COLOR_ORANGE	"{FFBB00}"
#define	COLOR_PURPLE	"{FF00FF}"
#define	COLOR_GREY		"{AFAFAF}"
#define	COLOR_LIGHTBLUE	"{0AFFFF}"

#define	COL_BLACK		0x000000AA
#define	COL_WHITE		0xFFFFFFAA
#define	COL_GREEN		0x00FF00AA
#define	COL_RED			0xFF0000AA
#define	COL_BLUE		0x0000FFAA
#define	COL_YELLOW		0xFFFF00AA
#define	COL_ORANGE		0xFFBB00AA
#define	COL_PURPLE		0xFF00FFAA
#define	COL_GREY		0xAFAFAFAA
#define	COL_LIGHTBLUE	0x0AFFFFAA
//Dialogs
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
//Users path
#define PATH "/users/%s.ini"
//#define COL_LIGHTBLUE "{485CFF}"

new aVehicleNames[212][] =
{
	{"Landstalker"},
	{"Bravura"},
	{"Buffalo"},
	{"Linerunner"},
	{"Perrenial"},
	{"Sentinel"},
	{"Dumper"},
	{"Firetruck"},
	{"Trashmaster"},
	{"Stretch"},
	{"Manana"},
	{"Infernus"},
	{"Voodoo"},
	{"Pony"},
	{"Mule"},
	{"Cheetah"},
	{"Ambulance"},
	{"Leviathan"},
	{"Moonbeam"},
	{"Esperanto"},
	{"Taxi"},
	{"Washington"},
	{"Bobcat"},
	{"Mr Whoopee"},
	{"BF Injection"},
	{"Hunter"},
	{"Premier"},
	{"Enforcer"},
	{"Securicar"},
	{"Banshee"},
	{"Predator"},
	{"Bus"},
	{"Rhino"},
	{"Barracks"},
	{"Hotknife"},
	{"Trailer 1"},
	{"Previon"},
	{"Coach"},
	{"Cabbie"},
	{"Stallion"},
	{"Rumpo"},
	{"RC Bandit"},
	{"Romero"},
	{"Packer"},
	{"Monster"},
	{"Admiral"},
	{"Squalo"},
	{"Seasparrow"},
	{"Pizzaboy"},
	{"Tram"},
	{"Trailer 2"},
	{"Turismo"},
	{"Speeder"},
	{"Reefer"},
	{"Tropic"},
	{"Flatbed"},
	{"Yankee"},
	{"Caddy"},
	{"Solair"},
	{"Berkley's RC Van"},
	{"Skimmer"},
	{"PCJ-600"},
	{"Faggio"},
	{"Freeway"},
	{"RC Baron"},
	{"RC Raider"},
	{"Glendale"},
	{"Oceanic"},
	{"Sanchez"},
	{"Sparrow"},
	{"Patriot"},
	{"Quad"},
	{"Coastguard"},
	{"Dinghy"},
	{"Hermes"},
	{"Sabre"},
	{"Rustler"},
	{"ZR-350"},
	{"Walton"},
	{"Regina"},
	{"Comet"},
	{"BMX"},
	{"Burrito"},
	{"Camper"},
	{"Marquis"},
	{"Baggage"},
	{"Dozer"},
	{"Maverick"},
	{"News Chopper"},
	{"Rancher"},
	{"FBI Rancher"},
	{"Virgo"},
	{"Greenwood"},
	{"Jetmax"},
	{"Hotring"},
	{"Sandking"},
	{"Blista Compact"},
	{"Police Maverick"},
	{"Boxville"},
	{"Benson"},
	{"Mesa"},
	{"RC Goblin"},
	{"Hotring Racer A"},
	{"Hotring Racer B"},
	{"Bloodring Banger"},
	{"Rancher"},
	{"Super GT"},
	{"Elegant"},
	{"Journey"},
	{"Bike"},
	{"Mountain Bike"},
	{"Beagle"},
	{"Cropdust"},
	{"Stunt"},
	{"Tanker"},
	{"Roadtrain"},
	{"Nebula"},
	{"Majestic"},
	{"Buccaneer"},
	{"Shamal"},
	{"Hydra"},
	{"FCR-900"},
	{"NRG-500"},
	{"HPV1000"},
	{"Cement Truck"},
	{"Tow Truck"},
	{"Fortune"},
	{"Cadrona"},
	{"FBI Truck"},
	{"Willard"},
	{"Forklift"},
	{"Tractor"},
	{"Combine"},
	{"Feltzer"},
	{"Remington"},
	{"Slamvan"},
	{"Blade"},
	{"Freight"},
	{"Streak"},
	{"Vortex"},
	{"Vincent"},
	{"Bullet"},
	{"Clover"},
	{"Sadler"},
	{"Firetruck LA"},
	{"Hustler"},
	{"Intruder"},
	{"Primo"},
	{"Cargobob"},
	{"Tampa"},
	{"Sunrise"},
	{"Merit"},
	{"Utility"},
	{"Nevada"},
	{"Yosemite"},
	{"Windsor"},
	{"Monster A"},
	{"Monster B"},
	{"Uranus"},
	{"Jester"},
	{"Sultan"},
	{"Stratum"},
	{"Elegy"},
	{"Raindance"},
	{"RC Tiger"},
	{"Flash"},
	{"Tahoma"},
	{"Savanna"},
	{"Bandito"},
	{"Freight Flat"},
	{"Streak Carriage"},
	{"Kart"},
	{"Mower"},
	{"Duneride"},
	{"Sweeper"},
	{"Broadway"},
	{"Tornado"},
	{"AT-400"},
	{"DFT-30"},
	{"Huntley"},
	{"Stafford"},
	{"BF-400"},
	{"Newsvan"},
	{"Tug"},
	{"Trailer 3"},
	{"Emperor"},
	{"Wayfarer"},
	{"Euros"},
	{"Hotdog"},
	{"Club"},
	{"Freight Carriage"},
	{"Trailer 3"},
	{"Andromada"},
	{"Dodo"},
	{"RC Cam"},
	{"Launch"},
	{"Police Car (LSPD)"},
	{"Police Car (SFPD)"},
	{"Police Car (LVPD)"},
	{"Police Ranger"},
	{"Picador"},
	{"S.W.A.T. Van"},
	{"Alpha"},
	{"Phoenix"},
	{"Glendale"},
	{"Sadler"},
	{"Luggage Trailer A"},
	{"Luggage Trailer B"},
	{"Stair Trailer"},
	{"Boxville"},
	{"Farm Plow"},
	{"Utility Trailer"}
};

//Information
main()
{
	print("Roleplaying script loaded!");
	return 1;
}

public OnGameModeInit()
{
	AddPlayerClass(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    DisableInteriorEnterExits();
	print("Gamemode Started.");
	return 1;
}
//Public things

///Public things
//Chat
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}

stock GetName(playerid)
{
    new
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, '_', ' ');
    return name;
}

stock ProxDetector(Float:radi, playerid, string[],color)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    foreach(Player,i)
    {
        if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
        {
            SendClientMessage(i,color,string);
        }
    }
}

public OnPlayerText(playerid, text[])
{
    new message[128];
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    ProxDetector(30.0, playerid, message, -1);
    return 0;

}
///Chat

//Login
enum pInfo
{
    pPass,
    pRights,
    pLevel,
    pCash,
    pSkin,
    pKills,
    pDeaths,
    pHouse
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Rights",PlayerInfo[playerid][pRights]);
    INI_Int("Level",PlayerInfo[playerid][pLevel]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("House",PlayerInfo[playerid][pHouse]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        new string[128], playerName[24];
		GetPlayerName(playerid, playerName, sizeof(playerName));
		format(string, sizeof(string), ""COLOR_YELLOW"Welcome back "COLOR_LIGHTBLUE"%s "COLOR_WHITE"\nplease type your password below to log in.", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, COLOR_WHITE"Login", string, "Login", "Quit");
    }
    else
    {
    	new string[128], playerName[24];
		GetPlayerName(playerid, playerName, sizeof(playerName));
        format(string, 128, COLOR_YELLOW"Welcome "COLOR_LIGHTBLUE"%s "COLOR_WHITE"\n Type your password below to register a new account.", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, COLOR_WHITE"Registering...", string, "Register", "Quit");
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid); //i dont know your variables
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COLOR_WHITE"Registering...",""COLOR_RED"You have entered an invalid password.\n"COLOR_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Rights",0);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Level",0);
                INI_WriteInt(File,"Skin",79);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"House",0);
                INI_Close(File);
                
                SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
                SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
                SpawnPlayer(playerid);
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
                    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
                    SpawnPlayer(playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Rights",PlayerInfo[playerid][pRights]);
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Level",GetPlayerScore(playerid));
    INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"House",PlayerInfo[playerid][pHouse]);
    INI_Close(File);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
    return 1;
}
///Login

//Commands
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/help", true))
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "Vehicle");
		SendClientMessage(playerid, 0xFFFFFFFF, "Use it like /help vehicle");
		return 1;
	}
	/*CMD:help(playerid, params)
	{
        SendClientMessage(playerid, 0xFFFFFFFF, "Vehicle");
		SendClientMessage(playerid, 0xFFFFFFFF, "Use it like /help vehicle");
		return 1;
	}*/
    if(!strcmp(cmdtext, "/help Vehicle", true))
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "e");
		return 1;
	}
	/*CMD:help vehicle(playerid, params)
	{
        SendClientMessage(playerid, 0xFFFFFFFF, "e");
		return 1;
	}*/
	if(!strcmp(cmdtext, "/e", true))
	{
		return 1;
	}
	/*CMD:e(playerid, params)
	{
		return 1;
	}*/
	if(!strcmp(cmdtext, "/me", true, 3))
	{
	    if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
	    new message[128];
        format(message, sizeof(message), "> %s %s", GetName(playerid), cmdtext[4]);
       // SendClientMessageToAll(0xC2A2DAAA, str);
        ProxDetector(30.0, playerid, message, 0xC2A2DAAA);
		return 1;
	}
	/*CMD:me(playerid, params)
	{
		if(!cmdtext[3]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
		new message[128];
		format(message, sizeof(mesage), "> %s %s", GetName(playerid), cmdtext[4]);
		ProxDetector(30.0, playerid, message, 0xC2A2DAAA);
		return 1;
	}*/
	if(!strcmp(cmdtext, "/act", true ,4))
	{
	    if(!cmdtext [3]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /act [action]");
	    new message[128];
		format(message, sizeof(message), "> %s ((%s))", cmdtext[5], GetName(playerid));
		//SendClientMessageToAll(0xC2A2DAAA, str);
		ProxDetector(30.0, playerid, message, 0xC2A2DAAA);
		return 1;
	}
	/*CMD:act(playerid, params)
	{
		if(!cmdtext[3]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /act [action]");
		new message[128];
		format(message, sizeof(message), "> %s ((%s))", cmdtext[5], GetName(playerid));
		ProxDetector(30.0, playerid, message, 0xC2A2DAAA);
		return 1;
	}*/
	new cmd[200], idx;
	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/car", true, 10) == 0)
	{
		if (PlayerInfo[playerid][pRights] == 3) {
		new String[200];
		new tmp[256];
		new Float:x, Float:y, Float:z;

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid, COL_RED, "You didn't give a vehicle name");

		new vehicle = GetVehicleModelIDFromName(tmp);

		if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, COL_RED, "That vehicle name was not found");

		new Float:a;
		GetPlayerFacingAngle(playerid, a);
		GetPlayerPos(playerid, x, y, z);

		if(IsPlayerInAnyVehicle(playerid) == 1)
		{
			GetXYInFrontOfPlayer(playerid, x, y, 8);
		}
		else
		{
		    GetXYInFrontOfPlayer(playerid, x, y, 5);
		}

		new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
		LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));

		format(String, sizeof(String), "You have spawned a %s", aVehicleNames[vehicle - 400]);
		SendClientMessage(playerid, COL_GREEN, String);
		} else {
		SendClientMessage(playerid, COL_RED, "You don't have to rights to use this command.");
		}
		return 1;
	}
	return 0;
}

/*CMD:giverights(playerid, params[])
{
    if(PlayerInfo[playerid][pRights] < 3) return 0;
    new target, rights, Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
    if(sscanf(params, "ud", target,rights)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /giverights [playerid] [level]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COL_GREY, "Player is not connected!");
    GetPlayerName(playerid, Adminname, sizeof(Adminname));
    GetPlayerName(target, Playername, sizeof(Playername));
    PlayerInfo[target][pRights] = rights;
    return 1;
}*/

///Commands

strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}

GetVehicleModelIDFromName(vname[])
{
	for(new i = 0; i < 211; i++)
	{
		if(strfind(aVehicleNames[i], vname, true) != -1)
		return i + 400;
	}
	return -1;
}

stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
{
	new Float:a;

	GetPlayerPos(playerid, x2, y2, a);
	GetPlayerFacingAngle(playerid, a);

	if(GetPlayerVehicleID(playerid))
	{
		GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
	}

	x2 += (distance * floatsin(-a, degrees));
	y2 += (distance * floatcos(-a, degrees));
}
Reply
#2

is the Streamer Plugin load when you open the Server ?
Reply
#3

Quote:
Originally Posted by GGW
Посмотреть сообщение
is the Streamer Plugin load when you open the Server ?
Sorry, sorry, sorry. I meant scanf
Reply
#4

make sure your sscanf plugin is loaded
Reply
#5

This is my server.cfg
Код:
echo Executing Server Config...
lanmode 0
rcon_password *
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0 RP
plugins sscanf
announce 0
query 1
chatlogging 0
weburl www.sa-mp.com
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 0
logtimeformat [%H:%M:%S]
Reply
#6

your codes isn't right , ZCMD is Different from strcmp

for example /me cmd should be like this

pawn Код:
CMD:me(playerid, params[])
{
    new text[128], message[128];
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    format(message, 128, "> %s %s", GetName(playerid), text);
    SendClientMessageToAll(lightblue, message);
    return 1;
}
Reply
#7

Quote:
Originally Posted by GGW
Посмотреть сообщение
your codes isn't right , ZCMD is Different from strcmp

for example /me cmd should be like this

pawn Код:
CMD:me(playerid, params[])
{
    new text[128], message[128];
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    format(message, 128, "> %s %s", GetName(playerid), text);
    SendClientMessageToAll(lightblue, message);
    return 1;
}
Can you explain each line?
Reply
#8

I will explain to you

pawn Код:
CMD:me(playerid, params[]) // Default look of a command, CMD or COMMAND; "me" is the name of a command, these things in ( ) I will explaim now
{
    new text[128], message[128]; // text is a string and 128 is it's length, message is the same as text
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    //sscanf is using some parameters, so: "s" means string text and a number in brackets how many characters(text) do you need, 128 is max for SAMP chat; text is that string that we store in our "s". So if a player doesn't type all of required information of a command, let the server return him a message how to do it!
    format(message, 128, "> %s %s", GetName(playerid), text); // we format a message that we'll send. Now we use our previously created string called "message" and use that for formating, then size of a message which is 128, "%s" string holder and other I believe you know what it does.
    SendClientMessageToAll(lightblue, message);
    return 1;
}
Also, this is better way to do it. Commands like /me, /do, /b use only one parameter and that is "s". So we can do this

pawn Код:
CMD:me(playerid, params[])
{
    new string[128]; // one string will be enough
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]"); // if the only paramter "s" for string is null or we didn't typed anything(blank), let us return a message to a silly player
    format(string, sizeof(string), "* %s %s", GetName(playerid), params); //Now we format it and put our message into a string. Same as before, we use %s placeholders for player names and this time "params" which is our message we typed. GetName is function for getting player's name , I will put it below
    SendClientMessageToAll(0xFF0000FF, string);
    return 1;
}

GetName(playerid) // Get player's name
{
    new name[MAX_PLAYER_NAME]; // string for a name, max player name is 24 I think
    GetPlayerName(playerid, name, sizeof(name)); // using default samp native for getting player name
    return name; // returning the name
}
Reply
#9

Quote:
Originally Posted by Sime30
Посмотреть сообщение
I will explain to you

pawn Код:
CMD:me(playerid, params[]) // Default look of a command, CMD or COMMAND; "me" is the name of a command, these things in ( ) I will explaim now
{
    new text[128], message[128]; // text is a string and 128 is it's length, message is the same as text
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    //sscanf is using some parameters, so: "s" means string text and a number in brackets how many characters(text) do you need, 128 is max for SAMP chat; text is that string that we store in our "s". So if a player doesn't type all of required information of a command, let the server return him a message how to do it!
    format(message, 128, "> %s %s", GetName(playerid), text); // we format a message that we'll send. Now we use our previously created string called "message" and use that for formating, then size of a message which is 128, "%s" string holder and other I believe you know what it does.
    SendClientMessageToAll(lightblue, message);
    return 1;
}
Also, this is better way to do it. Commands like /me, /do, /b use only one parameter and that is "s". So we can do this

pawn Код:
CMD:me(playerid, params[])
{
    new string[128]; // one string will be enough
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]"); // if the only paramter "s" for string is null or we didn't typed anything(blank), let us return a message to a silly player
    format(string, sizeof(string), "* %s %s", GetName(playerid), params); //Now we format it and put our message into a string. Same as before, we use %s placeholders for player names and this time "params" which is our message we typed. GetName is function for getting player's name , I will put it below
    SendClientMessageToAll(0xFF0000FF, string);
    return 1;
}

GetName(playerid) // Get player's name
{
    new name[MAX_PLAYER_NAME]; // string for a name, max player name is 24 I think
    GetPlayerName(playerid, name, sizeof(name)); // using default samp native for getting player name
    return name; // returning the name
}
Why is it better to use that other code?
Reply
#10

Basically, sscanf has isnull in-build code so you can check wether the string is 0(isnull) or >0 (!isnull). With using params and isnull function, there is no need for extra variables and strings. Less lines, less space used..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)