zcmd and sscanf problem
#9

Quote:
Originally Posted by Sky4D
Посмотреть сообщение
Well, since I need a PM command in my script anyway, let me create one real fast and you can edit it to your needs....

2 - 3 minutes later:

pawn Код:
COMMAND:pm(playerid, params[])
{
    new user, yourmessage[128], string[128];
    if(!sscanf(params, "us", user, yourmessage))
    {
        if(user != INVALID_PLAYER_ID)
        {
            format(string, sizeof(string), "[Private Message from %s]: %s", ReturnPlayerName(playerid), yourmessage);
            SendClientMessage(user, sc_Lime, string);
            format(string, sizeof(string), "[Private Message to %s]: %s", ReturnPlayerName(playerid), yourmessage);
            SendClientMessage(playerid, sc_Lime, string);
        }
        else return SendClientMessage(playerid, sc_LightRed, "ERROR: Invalid Player ID.");
    }
    else return SendClientMessage(playerid, sc_White, "COMMAND: /pm [playerid] [message]");
    return 1;
}
ReturnPlayerName:

pawn Код:
stock ReturnPlayerName(playerid)
{
    var1="Invalid_Player_ID";
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, var1, sizeof(var1));
        for(new i = 0; i < sizeof(var1); i++)
        { if(var1[i] == '_') { var1[i] = ' '; } }
    }
    return var1;
}
An entire function to return a silly player's name?

Quote:
Originally Posted by FreshKilla
Посмотреть сообщение
pawn Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str2)) SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id/name> <message>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: That player is not connected!");
    if(playerid != id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
    GetPlayerName(playerid, Name1, sizeof(Name2)); //The Sender's Name so we use (playerid).
    GetPlayerName(id, Name2, sizeof(Name2)); //The Receiver's Name so we use (id).
    format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
    SendClientMessage(playerid, 0xFF0000FF, str);
    format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
    SendClientMessage(id, 0xFF0000FF, str);
    return 1;
}
Still not gunna work!

Quote:
Originally Posted by mrcoolballs
Посмотреть сообщение
ok well i changed my code but how come when i test it out ingame, i will type /pm and it returns unknown command?
ive made a few commands and all of them return unknown command, and i dont have them under any callback

EDIT:::::


Okay i figured out the problem, i get the error runtime error 19 so thta means that the file is notproperly included if somebody could please tell me where to put the files of sscanf2 please, i already have it in my Pawno/includes
and it the plugins folder what else is there?
Make sure you have the latest includes. Make sure the plugin is mentioned in server.cfg, make sure the include is mentioned at the top of your gamemode and make sure you're compiling with the latest includes.
Reply


Messages In This Thread
zcmd and sscanf problem - by mrcoolballs - 23.08.2010, 21:24
Re: zcmd and sscanf problem - by nemesis- - 23.08.2010, 21:31
Re: zcmd and sscanf problem - by mrcoolballs - 23.08.2010, 21:32
Re: zcmd and sscanf problem - by nemesis- - 23.08.2010, 21:35
Re: zcmd and sscanf problem - by Sky4D - 23.08.2010, 21:37
Re: zcmd and sscanf problem - by FreshKilla - 23.08.2010, 21:40
Re: zcmd and sscanf problem - by [L3th4l] - 23.08.2010, 21:43
Re: zcmd and sscanf problem - by mrcoolballs - 23.08.2010, 21:45
Re: zcmd and sscanf problem - by nemesis- - 23.08.2010, 22:08
Re: zcmd and sscanf problem - by Sky4D - 23.08.2010, 22:10

Forum Jump:


Users browsing this thread: 2 Guest(s)