public OnPlayerCommandText(playerid, cmdtext[]) { // MEDIC COMMANDS dcmd(heal,4,cmdtext); return 0; } dcmd_heal(playerid,params[]) { new id; if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal [ID]\""); ---------------> LINE 614 else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayername)); -------------------------------> LINE 618 GetPlayerName(playerid, sendername, sizeof(healername)); SetPlayerHealth(id, 100.0); format(string, sizeof(string),"You Have Been Healed By Medic %s[%d]", healername, playerid); SendClientMessage(id, 0x33CCFFAA,string); // Light Blue Color format(string, sizeof(string),"You Healed Player %s[%d],You Get $13", giveplayername, id); SendClientMessage(playerid, 0x00FF00AA, "Player healed"); GivePlayerMoney(playerid,13); } return 1; }
C:\Documents and Settings\samp\Desktop\Server2\gamemodes\WeedsCNR.pwn(614) : error 017: undefined symbol "sscanf" C:\Documents and Settings\samp\Desktop\Server2\gamemodes\WeedsCNR.pwn(618) : error 017: undefined symbol "giveplayerid" C:\Documents and Settings\samp\Desktop\Server2\gamemodes\WeedsCNR.pwn(618) : error 017: undefined symbol "giveplayername" C:\Documents and Settings\samp\Desktop\Server2\gamemodes\WeedsCNR.pwn(618) : error 029: invalid expression, assumed zero C:\Documents and Settings\samp\Desktop\Server2\gamemodes\WeedsCNR.pwn(618) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 5 Errors.
cmd(heal, playerid, params[])
{
new user;
if(!sscanf(params, "u", user))
{
SetPlayerHealth(user, 100);
//Message
}
else return SendClientMessage(playerid, white, "(USAGE): /Heal (Player ID)");
return 1;
}
Originally Posted by Lajko1
o.O so much commands ... sscanf , zcmd,strmpc or what ever it is ... dcmd wtf is the best to use ? lol
|
Originally Posted by Don Correlli
Quote:
|
Originally Posted by Lajko1
but for sscanf i need to download something as ****** say , where to get that ?
|
Originally Posted by Y_Leѕѕ
Quote:
strcmp: This is just a native function which returns the lexical difference between two strings. You don't need to know what that means, just that if two strings are the same it returns 0. This was originally use to check if the command a person typed was the same as a command you had defined. dcmd: This is a wrapper around strcmp. When you have commands with parameters you want to be able to check they typed a command without looking at the parameters. The original way of doing this was to split the string up into multiple strings, but this is very slow, so dcmd was developed to provide a simple way of only looking at part of a string and checking it's value. It also called code in a function so that you didn't have a single huge OnPlayerCommandText, just a list of commands and their code elsewhere. zcmd: This is the latest best system for processing commands. It doesn't use strcmp at all, instead uses CallLocalFunction to try call a defined function directly. If the function doesn't exist nothing happens, if it does it's executed. The advantage to this is that you don't have to look through every command (you don't need a list of them anywhere in fact, you just write the code). It takes advantage of the much faster internal lookups of the PAWN VM. sscanf: This is nothing to do with any of the three concepts above, it's just often used in the same place. sscanf looks at a string and extracts information from it. You COULD use this information to check parameters entered with a command, but you can also use it anywhere else. strtok: I should mention this here for completeness. Before sscanf was developed this was used to split a string up into "tokens" (individual words) and those tokens were used, generally as command parameters, but as with sscanf this wasn't it's only use. The problem with this is code bloat as you have to check a token exists, check it's valid, convert it, check it's still valid and then use it. Any data returned from sscanf is guaranteed to be valid as all the checks are performed internally. This is VERY useful for beginner scripters who may not be aware of every bug and possible exploit so don't check for them then wonder how people hacked their script. ycmd: Because I wrote it I want to mention it. ycmd was developed between dcmd and zcmd and although it uses the same call method as zcmd I never put two and two together to create a zcmd like system. The difference to ycmd is that it's integrated into YSI (although a stand alone version is theoretically possible) and has many more options than other command processors. Normal processors have a command, and that is the command, ycmd can dynamically rename commands, give different commands to different people doing the same thing, add and remove commands, add or remove prefixes to all commands from a certain script (including optional spacing) and includes command usage checks internally so you don't need to make the first line of every command "if (IsPlayerAdmin(playerid))". This is also highly optimised for large numbers of commands, but so is zcmd. The downside to all this is that, especially for low numbers of commands, it's slower than dcmd, but frankly I still think it's MUCH better for huge modes. |