[Help] sscanf+YSI
#1

I wanted to try to make something from scratch using YSI, because I had just decided to use it.
And I wanted to make something a bit more advanced, because I'm just a bit above a novice.

So here is my script:
Код:
#include <a_samp>
#define FILTERSCRIPT
#include <YSI>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
//________________________________________________________________________________________
Script_OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(deal, 4, cmdtext);
{
dcmd(acceptdeal, 10, cmdtext);
return 0;
}

dcmd_deal(playerid, params[])
{
new id,
text1[128],
text2[210],
deal[200],
offered,
playername[MAX_PLAYER_NAME];
if (sscanf(params, "us", id, deal))
return Text_Send(playerid, 0xFF0000AA, "USAGE: \"/deal <playerid> <text>\""), 1;
if ( ! IsPlayerConnected(id) ) Text_Send(playerid, 0xFF0000AA, "Player Offline");
else
{
GetPlayerName(id, playername, MAX_PLAYER_NAME);
format(text1, 127, "%s Wants you to accept a contract, the contract is as follows:", playername);
format(text2, 199, "** %s **", deal);
Text_Send(id, 0xFF0000AA, text1);
Text_Send(id, 0x9EC73DAA, text2);
Text_Send(id, 0xFF0000AA, "If you would like to accept please type /acceptdeal.");
offered = 1;
return 1;
}

dcmd_acceptdeal(playerid, params[])
{
new id,
accepted,
text3[100],
playername[MAX_PLAYER_NAME];
if offered = 1;
GetPlayerName(id, playername, MAX_PLAYER_NAME);
Text_Send(id, 0xFF0000AA, "You have accepted the deal, signing your name at the bottom");
format(text3, 99, "* %s grabs a pen, and continues to sign the contract, accepting it.", playername);
ProxDetector(30.0, playerid, text3,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
accepted = 1;
return 1;
Surprisngly at this point it compiled well, except for something in the YSI include failed..

Here are my errors:
Код:
include\YSI/System/YSI_default.own(601) : error 004: function "OnPlayerRequestClassExFS" is not implemented
include\YSI/System/YSI_default.own(808) : error 004: function "OnPlayerRequestSpawnExFS" is not implemented
(44) : warning 203: symbol is never used: "Langs_AddFile"
(44 -- 350) : warning 203: symbol is never used: "Langs_AddLanguage"
(44 -- 350) : warning 203: symbol is never used: "Script_OnPlayerCommandText"
Help me please?
Reply
#2

Код:
(44) : warning 203: symbol is never used: "Langs_AddFile"
(44 -- 350) : warning 203: symbol is never used: "Langs_AddLanguage"
(44 -- 350) : warning 203: symbol is never used: "Script_OnPlayerCommandText"
To fix that, easily add

pawn Код:
#pragma unused Langs_AddFile
#pragma unused Langs_AddLanguage
#pragma unused Script_OnPlayerCommandText
under the

pawn Код:
#include a_samp
Reply
#3

Thanks alot!

That gets me down to the two unexplained errors inside of YSI.

The Two Errors:
Код:
include\YSI/System/YSI_default.own(601) : error 004: function "OnPlayerRequestClassExFS" is not implemented
include\YSI/System/YSI_default.own(808) : error 004: function "OnPlayerRequestSpawnExFS" is not implemented
Here's an updated version:
pawn Код:
#include <a_samp>
#pragma unused Langs_AddFile
#pragma unused Langs_AddLanguage
#define FILTERSCRIPT
#include <YSI>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
//________________________________________________________________________________________
stock Script_OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(deal, 4, cmdtext);
{
dcmd(acceptdeal, 10, cmdtext);
return 0;
}

dcmd_deal(playerid, params[])
{
new id,
text1[128],
text2[210],
deal[200],
offered,
playername[MAX_PLAYER_NAME];
if (sscanf(params, "us", id, deal))
return Text_Send(playerid, 0xFF0000AA, "USAGE: \"/deal <playerid> <text>\""), 1;
if ( ! IsPlayerConnected(id) ) Text_Send(playerid, 0xFF0000AA, "Player Offline");
else
{
GetPlayerName(id, playername, MAX_PLAYER_NAME);
format(text1, 127, "%s Wants you to accept a contract, the contract is as follows:", playername);
format(text2, 199, "** %s **", deal);
Text_Send(id, 0xFF0000AA, text1);
Text_Send(id, 0x9EC73DAA, text2);
Text_Send(id, 0xFF0000AA, "If you would like to accept please type /acceptdeal.");
offered = 1;
return 1;
}

dcmd_acceptdeal(playerid, params[])
{
new id,
accepted,
text3[100],
playername[MAX_PLAYER_NAME];
if offered = 1;
GetPlayerName(id, playername, MAX_PLAYER_NAME);
Text_Send(id, 0xFF0000AA, "You have accepted the deal, signing your name at the bottom");
format(text3, 99, "* %s grabs a pen, and continues to sign the contract, accepting it.", playername);
ProxDetector(30.0, playerid, text3,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
accepted = 1;
return 1;
}
else
{
    Text_Send(id, 0xFF0000AA, "No one offered you a contract, dude.");
    return 1;
}
Reply
#4

OnPlayerRequestClassExFS doesn't include in your script. Is that the full script?
Reply
#5

Quote:
Originally Posted by cοοp
OnPlayerRequestClassExFS doesn't include in your script. Is that the full script?
No, I excluded the sscanf code.
And, the ProxDetector, stock.

Other than that, that's all of it.
Reply
#6

Then confined them. Then I could maybe help you. :P
Reply
#7

Okee Dokie, then. Here's the whole thing.

pawn Код:
#include <a_samp>
#pragma unused Langs_AddFile
#pragma unused Langs_AddLanguage
#define FILTERSCRIPT
#include <YSI>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
//________________________________________________________________________________________
stock Script_OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(deal, 4, cmdtext);
{
dcmd(acceptdeal, 10, cmdtext);
return 0;
}

dcmd_deal(playerid, params[])
{
new id,
text1[128],
text2[210],
deal[200],
offered,
playername[MAX_PLAYER_NAME];
if (sscanf(params, "us", id, deal))
return Text_Send(playerid, 0xFF0000AA, "USAGE: \"/deal <playerid> <text>\""), 1;
if ( ! IsPlayerConnected(id) ) Text_Send(playerid, 0xFF0000AA, "Player Offline");
else
{
GetPlayerName(id, playername, MAX_PLAYER_NAME);
format(text1, 127, "%s Wants you to accept a contract, the contract is as follows:", playername);
format(text2, 199, "** %s **", deal);
Text_Send(id, 0xFF0000AA, text1);
Text_Send(id, 0x9EC73DAA, text2);
Text_Send(id, 0xFF0000AA, "If you would like to accept please type /acceptdeal.");
offered = 1;
return 1;
}

dcmd_acceptdeal(playerid, params[])
{
new id,
accepted,
text3[100],
playername[MAX_PLAYER_NAME];
if offered = 1;
GetPlayerName(id, playername, MAX_PLAYER_NAME);
Text_Send(id, 0xFF0000AA, "You have accepted the deal, signing your name at the bottom");
format(text3, 99, "* %s grabs a pen, and continues to sign the contract, accepting it.", playername);
ProxDetector(30.0, playerid, text3,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
accepted = 1;
return 1;
}
else
{
    Text_Send(id, 0xFF0000AA, "No one offered you a contract, dude.");
    return 1;
}




public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        //radi = 2.0; //Trigger Radius
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
            {
                if(!BigEar[i])
                {
                    GetPlayerPos(i, posx, posy, posz);
                    tempposx = (oldposx -posx);
                    tempposy = (oldposy -posy);
                    tempposz = (oldposz -posz);
                    //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
                    if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                    {
                        SendClientMessage(i, col1, string);
                    }
                    else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                    {
                        SendClientMessage(i, col2, string);
                    }
                    else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                    {
                        SendClientMessage(i, col3, string);
                    }
                    else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                    {
                        SendClientMessage(i, col4, string);
                    }
                    else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                    {
                        SendClientMessage(i, col5, string);
                    }
                }
                else
                {
                    SendClientMessage(i, col1, string);
                }
            }
        }
    }//not connected
    return 1;
}

//________________________________________________________________________________________
stock sscanf(string[], format[], {Float,_}:...)
{
    #if defined isnull
        if (isnull(string))
    #else
        if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
    #endif
        {
            return format[0];
        }
    #pragma tabsize 4
    new
        formatPos = 0,
        stringPos = 0,
        paramPos = 2,
        paramCount = numargs(),
        delim = ' ';
    while (string[stringPos] && string[stringPos] <= ' ')
    {
        stringPos++;
    }
    while (paramPos < paramCount && string[stringPos])
    {
        switch (format[formatPos++])
        {
            case '\0':
            {
                return 0;
            }
            case 'i', 'd':
            {
                new
                    neg = 1,
                    num = 0,
                    ch = string[stringPos];
                if (ch == '-')
                {
                    neg = -1;
                    ch = string[++stringPos];
                }
                do
                {
                    stringPos++;
                    if ('0' <= ch <= '9')
                    {
                        num = (num * 10) + (ch - '0');
                    }
                    else
                    {
                        return -1;
                    }
                }
                while ((ch = string[stringPos]) > ' ' && ch != delim);
                setarg(paramPos, 0, num * neg);
            }
            case 'h', 'x':
            {
                new
                    num = 0,
                    ch = string[stringPos];
                do
                {
                    stringPos++;
                    switch (ch)
                    {
                        case 'x', 'X':
                        {
                            num = 0;
                            continue;
                        }
                        case '0' .. '9':
                        {
                            num = (num << 4) | (ch - '0');
                        }
                        case 'a' .. 'f':
                        {
                            num = (num << 4) | (ch - ('a' - 10));
                        }
                        case 'A' .. 'F':
                        {
                            num = (num << 4) | (ch - ('A' - 10));
                        }
                        default:
                        {
                            return -1;
                        }
                    }
                }
                while ((ch = string[stringPos]) > ' ' && ch != delim);
                setarg(paramPos, 0, num);
            }
            case 'c':
            {
                setarg(paramPos, 0, string[stringPos++]);
            }
            case 'f':
            {
                setarg(paramPos, 0, _:floatstr(string[stringPos]));
            }
            case 'p':
            {
                delim = format[formatPos++];
                continue;
            }
            case '\'':
            {
                new
                    end = formatPos - 1,
                    ch;
                while ((ch = format[++end]) && ch != '\'') {}
                if (!ch)
                {
                    return -1;
                }
                format[end] = '\0';
                if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
                {
                    if (format[end + 1])
                    {
                        return -1;
                    }
                    return 0;
                }
                format[end] = '\'';
                stringPos = ch + (end - formatPos);
                formatPos = end + 1;
            }
            case 'u':
            {
                new
                    end = stringPos - 1,
                    id = 0,
                    bool:num = true,
                    ch;
                while ((ch = string[++end]) && ch != delim)
                {
                    if (num)
                    {
                        if ('0' <= ch <= '9')
                        {
                            id = (id * 10) + (ch - '0');
                        }
                        else
                        {
                            num = false;
                        }
                    }
                }
                if (num && IsPlayerConnected(id))
                {
                    setarg(paramPos, 0, id);
                }
                else
                {
                    #if !defined foreach
                        #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
                        #define __SSCANF_FOREACH__
                    #endif
                    string[end] = '\0';
                    num = false;
                    new
                        name[MAX_PLAYER_NAME];
                    id = end - stringPos;
                    foreach (Player, playerid)
                    {
                        GetPlayerName(playerid, name, sizeof (name));
                        if (!strcmp(name, string[stringPos], true, id))
                        {
                            setarg(paramPos, 0, playerid);
                            num = true;
                            break;
                        }
                    }
                    if (!num)
                    {
                        setarg(paramPos, 0, INVALID_PLAYER_ID);
                    }
                    string[end] = ch;
                    #if defined __SSCANF_FOREACH__
                        #undef foreach
                        #undef __SSCANF_FOREACH__
                    #endif
                }
                stringPos = end;
            }
            case 's', 'z':
            {
                new
                    i = 0,
                    ch;
                if (format[formatPos])
                {
                    while ((ch = string[stringPos++]) && ch != delim)
                    {
                        setarg(paramPos, i++, ch);
                    }
                    if (!i)
                    {
                        return -1;
                    }
                }
                else
                {
                    while ((ch = string[stringPos++]))
                    {
                        setarg(paramPos, i++, ch);
                    }
                }
                stringPos--;
                setarg(paramPos, i, '\0');
            }
            default:
            {
                continue;
            }
        }
        while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
        {
            stringPos++;
        }
        while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
        {
            stringPos++;
        }
        paramPos++;
    }
    do
    {
        if ((delim = format[formatPos++]) > ' ')
        {
            if (delim == '\'')
            {
                while ((delim = format[formatPos++]) && delim != '\'') {}
            }
            else if (delim != 'z')
            {
                return delim;
            }
        }
    }
    while (delim > ' ');
    return 0;
}
Reply
#8

I am a bit confused. Because there aren't any "OnPlayerRequestClassExFS" or "OnPlayerRequestSpawnExFS" in that code, then how does the errors come?
Reply
#9

Now you see my confusion aswell...

When this popped up, I thought "Yipeee, another fun Pawn moment"
Reply
#10

Add this at the bottom of your script:

pawn Код:
forward OnPlayerRequestClassExFS();
public OnPlayerRequestClassExFS()
{
CallRemoteFunction("OnPlayerRequestClass", "is", playerid);
return 0;
}

OnPlayerRequestSpawnExFS();
public OnPlayerRequestSpawnExFS()
{
CallRemoteFunction("OnPlayerRequestSpawn", "is", playerid);
return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)