plugins sscanf
plugins sscanf.so
#include <YSI\y_commands>
#include <sscanf2>
public OnPlayerConnect(playerid)
{
return 1;
}
YCMD:my_command(playerid, params[], help)
{
return 1;
}
YCMD:my_command(playerid, o[], help)
{
return 1;
}
YCMD:help(playerid, params[], help)
{
if (help) return SendClientMessage(playerid, -1, "Displays help about commands");
// If help system occured, "/help help" the player will get the message above.
if (isnull(params)) return SendClientMessage(playerid, -1, "Syntax Error: /help [Command]");
// If the parameters are null "/help" the player will get the syntax message above ( COLOR = -1 wich is some sort of black )
Command_ReProcess(playerid, params, true);
// Call to put text through the command processor, with the help functions enabled or disabled.
return 1;
}
YCMD:information(playerid, params[], help)
{
SendClientMessage(playerid, -1, "Tutorial by SmiT !");
return 1;
}
warning 203: symbol is never used "params" warning 203: symbol is never used "help"
YCMD:information(playerid, params[], help)
{
#pragma unused params, help
SendClientMessage(playerid, -1, "Tutorial by SmiT !");
return 1;
}
YCMD:information(playerid, params[], help)
{
if( help ) return SendClientMessage(playerid, -1, "This command displays some information");
// if parameter HELP occured, (player types "/help information") it will return the message above.
if( isnull( params ) ) // We check if the parameters are NULL. So it won't work something like "/information word".
{
SendClientMessage(playerid, -1, "Tutorial by SmiT !");
// So, if the parameters are null the player will get the message above.
}
return 1;
}
YCMD:ooc(playerid, params[], help)
{
new string[ 128 ];
new PlayerName[ MAX_PLAYER_NAME ];
if( help ) return SendClientMessage(playerid, -1, "With this command you can talk in OOC chat!");
if( isnull( params ) ) return SendClientMessage(playerid, -1, "Syntax Error: /ooc [Your Text]");
GetPlayerName( playerid, PlayerName, sizeof( PlayerName ) );
format( string, sizeof( string ),"(OOC CHAT) %s: %s", PlayerName, params);
SendClientMessageToAll(-1, string);
return 1;
}
new string[ 128 ];
new PlayerName[ MAX_PLAYER_NAME ];
new string[ 128 ], PlayerName[ MAX_PLAYER_NAME ];
if( help ) return SendClientMessage(playerid, -1, "With this command you can talk in OOC chat!");
if( isnull( params ) ) return SendClientMessage(playerid, -1, "Syntax Error: /ooc [Your Text]");
format( string, sizeof( string ),"(OOC CHAT) %s: %s", PlayerName, params);
(OOC CHAT) SmiT: Hello
%b Inserts a number at this position in binary radix. %c Inserts a single character. %d Inserts an integer (whole) number %f Inserts a floating point number. %i Inserts an integer. %s Inserts a string. ( We used this ) %x Inserts a number in hexadecimal notation. %% Inserts the literal '%'
public OnGameModeInit()
{
Command_AddAltNamed("information", "info");
return 1;
}
public OnFilterScriptInit()
{
Command_AddAltNamed("information", "info");
return 1;
}
YCMD:heal(playerid, params[], help)
{
new PlayerID;
if( help ) return SendClientMessage(playerid, -1, "With this command you can heal a player!");
if( sscanf( params, "u", PlayerID ) ) return SendClientMessage(playerid, -1, "Syntax Error: /heal [PlayerName / ID]");
if( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "[ERROR] This player is OFFLINE");
SetPlayerHealth(PlayerID, 100);
return 1;
}
if( help ) return SendClientMessage(playerid, -1, "With this command you can heal a player!");
if( sscanf( params, "u", PlayerID ) ) return SendClientMessage(playerid, -1, "Syntax Error: /heal [PlayerName / ID]");
if( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "[ERROR] This player is OFFLINE");
if( !sscanf( params, "specifiers_here", your_variables ) ) // If the player entered the CORRECT parameters ( NOTE the "!" )
{
// Do your code
}
if( sscanf ( params, "specifiers_here", your_variables ) ) // If the player entered the WRONG parameters
{
// Do your code
}
Код:
Format Use L(true/false) Optional logical truthity l Logical truthity B(binary) Optional binary number b Binary number N(any format number) Optional number n Number C(character) Optional character c Character I(integer) Optional integer i Integer D(integer) Optional integer d Integer H(hex value) Optional hex number h Hex number O(octal value) Optional octal value o Octal value F(float) Optional floating point number f Floating point number G(float/INFINITY/-INFINITY/NAN/NAN_E) Optional float with IEEE definitions g Float with IEEE definitions { Open quiet section } Close quiet section P<delimiter> Invalid delimiter change p<delimiter> Delimiter change Z(string)[length] Invalid optional string z(string)[length] Deprecated optional string S(string)[length] Optional string s[length] String U(name/id) Optional user (bot/player) u User (bot/player) Q(name/id) Optional bot (bot) q Bot (bot) R(name/id) Optional player (player) r Player (player) A<type>(default)[length] Optional array of given type a<type>[length] Array of given type E<specification>(default) Optional enumeration of given layout e<specification> Enumeration of given layout 'string' Search string % Deprecated optional specifier prefix |
YCMD:setskin(playerid, params[], help)
{
return 1;
}
YCMD:setskin(playerid, params[], help)
{
new PlayerID, SkinID, PlayerName[ MAX_PLAYER_NAME ], TargetName[ MAX_PLAYER_NAME ], string[ 128 ];
if( help ) return SendClientMessage(playerid, -1, "With this command you can change a player skin!");
if( sscanf( params, "ui", PlayerID, SkinID)) return SendClientMessage(playerid, -1, "Syntax Error: /setskin [PlayerName / ID] [SkinID]");
if( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "[ERROR] This player is OFFLINE");
if( SkinID > 299 || SkinID < 1 ) return SendClientMessage(playerid, -1, "Available SA:MP Skins: 1-299");
GetPlayerName( playerid, PlayerName, sizeof ( PlayerName ) );
GetPlayerName( PlayerID, TargetName, sizeof ( TargetName ) );
format( string, sizeof ( string ), "Your Skin has been set to ID: %d by %s", SkinID, PlayerName);
SendClientMessage(PlayerID, -1, string);
format( string, sizeof ( string ), "You have changed %s Skin to ID: %s", TargetName, SkinID);
SendClientMessage(playerid, -1, string);
SetPlayerSkin(PlayerID, SkinID);
return 1;
}
if( help ) return SendClientMessage(playerid, -1, "With this command you can change a player skin!");
if( sscanf( params, "ui", PlayerID, SkinID)) return SendClientMessage(playerid, -1, "Syntax Error: /setskin [PlayerName / ID] [SkinID]");
if( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "[ERROR] This player is OFFLINE");
if( SkinID > 299 || SkinID < 1 ) return SendClientMessage(playerid, -1, "Available SA:MP Skins: 1-299");
format( string, sizeof ( string ), "Your Skin has been set to ID: %d by %s", SkinID, PlayerName);
SendClientMessage(PlayerID, -1, string);
format( string, sizeof ( string ), "You have changed %s Skin to ID: %d", TargetName, SkinID);
SendClientMessage(playerid, -1, string);
YCMD:eat(playerid, params[], help)
{
new option[ 20 ];
if( help ) return SendClientMessage(playerid, -1,"With this command you can eat a Cookie or a Cake");
if( sscanf( params ,"s[20]", option) ) return SendClientMessage(playerid, -1,"Syntax Error: /eat [Cookie,Cake]");
if( !strcmp( option,"Cookie") )
{
SendClientMessage(playerid, -1, "You have ate a cookie! You have been healed to 100.");
SetPlayerHealth(playerid, 100);
}
else if( !strcmp( option,"Cake"))
{
SendClientMessage(playerid, -1, "You have ate a cake! You have been healed to 100.");
SetPlayerHealth(playerid, 100);
}
else return SendClientMessage(playerid, -1,"[ERROR] The option can only be Cookie or Cake.");
return 1;
}
if( help ) return SendClientMessage(playerid, -1,"With this command you can eat a Cookie or a Cake");
if( sscanf( params ,"s[20]", option) ) return SendClientMessage(playerid, -1,"Syntax Error: /eat [Cookie,Cake]");
if( !strcmp( option,"Cookie") )
else if( !strcmp( option,"Cake") )
else return SendClientMessage(playerid, -1,"[ERROR] The option can only be Cookie or Cake.");
public OnPlayerLogin(playerid)
{
if (IsPlayerAdmin ( playerid )) // If the player is logged into RCON
{
Command_SetPlayerNamed("setskin", playerid, true); // Enable the command for him
}
else // If the player is NOT logged into rcon
{
Command_SetPlayerNamed("help", playerid, false); // Disable the command for him
}
}
YCMD:commands(playerid, params[], help)
{
if ( help ) return SendClientMessage(playerid, -1, "Lists all the commands a player can use.");
new
count = Command_GetPlayerCommandCount( playerid );
for ( new i = 0; i != count; ++i) SendClientMessage( playerid, -1, Command_GetNext ( i, playerid ) );
return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if( !success ) return false;
return true;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if( !success )
{
format( cmdtext, 128, " ERROR: This command doesn't exists. Type /commands for a list of all available commands " );
SendClientMessage( playerid, -1, cmdtext );
}
return true;
}
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <YSI\y_commands>
#include <sscanf2>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
Command_AddAltNamed("information", "info");
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if( !success ) return false;
return true;
}
/* COMMANDS */
YCMD:help(playerid, params[], help)
{
if (help) return SendClientMessage(playerid, -1, "Displays help about commands");
if (isnull(params)) return SendClientMessage(playerid, -1, "Syntax Error: /help [Command]");
Command_ReProcess(playerid, params, true);
return 1;
}
YCMD:commands(playerid, params[], help)
{
if ( help ) return SendClientMessage(playerid, -1, "Lists all the commands a player can use.");
new
count = Command_GetPlayerCommandCount( playerid );
for ( new i = 0; i != count; ++i) SendClientMessage( playerid, -1, Command_GetNext ( i, playerid ) );
return 1;
}
YCMD:information(playerid, params[], help)
{
if( help ) return SendClientMessage(playerid, -1, "This command displays some information");
if( isnull( params ) )
{
SendClientMessage(playerid, -1, "Tutorial by SmiT !");
}
return 1;
}
YCMD:ooc(playerid, params[], help)
{
new string[ 128 ];
new PlayerName[ MAX_PLAYER_NAME ];
if( help ) return SendClientMessage(playerid, -1, "With this command you can talk in OOC chat!");
if( isnull( params ) ) return SendClientMessage(playerid, -1, "Syntax Error: /ooc [Your Text]");
GetPlayerName( playerid, PlayerName, sizeof( PlayerName ) );
format( string, sizeof( string ),"(OOC CHAT) %s: %s", PlayerName, params);
SendClientMessageToAll(-1, string);
return 1;
}
YCMD:heal(playerid, params[], help)
{
new PlayerID;
if( help ) return SendClientMessage(playerid, -1, "With this command you can heal a player!");
if( sscanf( params, "u", PlayerID ) ) return SendClientMessage(playerid, -1, "Syntax Error: /heal [PlayerName / ID]");
if( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "[ERROR] This player is OFFLINE");
SetPlayerHealth(PlayerID, 100);
return 1;
}
YCMD:setskin(playerid, params[], help)
{
new PlayerID, SkinID, PlayerName[ MAX_PLAYER_NAME ], TargetName[ MAX_PLAYER_NAME ], string[ 128 ];
if( help ) return SendClientMessage(playerid, -1, "With this command you can change a player skin!");
if( sscanf( params, "ui", PlayerID, SkinID)) return SendClientMessage(playerid, -1, "Syntax Error: /setskin [PlayerName / ID] [SkinID]");
if( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "[ERROR] This player is OFFLINE");
if( SkinID > 299 || SkinID < 1 ) return SendClientMessage(playerid, -1, "Available SA:MP Skins: 1-299");
GetPlayerName( playerid, PlayerName, sizeof ( PlayerName ) );
GetPlayerName( PlayerID, TargetName, sizeof ( TargetName ) );
format( string, sizeof ( string ), "Your Skin has been set to ID: %d by %s", SkinID, PlayerName);
SendClientMessage(PlayerID, -1, string);
format( string, sizeof ( string ), "You have changed %s Skin to ID: %s", TargetName, SkinID);
SendClientMessage(playerid, -1, string);
SetPlayerSkin(PlayerID, SkinID);
return 1;
}
YCMD:eat(playerid, params[], help)
{
new option[ 20 ];
if( help ) return SendClientMessage(playerid, -1,"With this command you can eat a Cookie or a Cake");
if( sscanf( params ,"s[20]", option) ) return SendClientMessage(playerid, -1,"Syntax Error: /eat [Cookie,Cake]");
if( !strcmp( option,"Cookie") )
{
SendClientMessage(playerid, -1, "You have ate a cookie! You have been healed to 100.");
SetPlayerHealth(playerid, 100);
}
else if( !strcmp( option,"Cookie"))
{
SendClientMessage(playerid, -1, "You have ate a cake! You have been healed to 100.");
SetPlayerHealth(playerid, 100);
}
else return SendClientMessage(playerid, -1,"[ERROR] The option can only be Cookie or Cake.");
return 1;
}
Zh3ro I so want to give youz rep but I can't due to yourself taking so many from me, anyhow I noticed that but it's detailed well.
|