SA-MP Forums Archive
/o(bject) list - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /o(bject) list (/showthread.php?tid=220872)



/o(bject) list - Majataka - 04.02.2011

Hei Again.

I would like to know how to create a "Search" thingy for /o(bjects)

And how to add "a object id list with "description" next to the ID - " to the /o command

So If I type in /o tree I will get

OBJECT ID - High Tree
OBJECT ID - Wide Tree
OBJECT ID - Christmas Tree
OBJECT ID - Tree Plank

And If I type /o B

OBJECT ID - Barrier
ID - Ball

See what I'm talking about? If yes.. Help me <3

If someone of you created a small filterscript for that ^ with 3 OBJECT id's on the list it would be awesome. Would figure the rest out myself


Re: /o(bject) list - Jefff - 04.02.2011

enum with id and names and in command strfind or strcmp and thats all.


Re: /o(bject) list - Majataka - 04.02.2011

Quote:
Originally Posted by Jefff
Посмотреть сообщение
enum with id and names and in command strfind or strcmp and thats all.
Yeah.. Easy for you to say.. But could you help me out?... I'm not a professional in PAWNO... I just know the basics


Re: /o(bject) list - Jefff - 04.02.2011

pawn Код:
#define MAX_OBJ 4
enum obj {
    oID,
    oName[24]
};
new Objects[MAX_OBJ][obj] = {
    {123,"High Tree"},
    {456,"Wide Tree"},
    {789,"Christmas Tree"},
    {101,"Tree Plank"}
};

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/o", true, 2)) {
        if(!strlen(cmdtext[3])) return SendClientMessage(playerid,0xFFFFFFFF,"Usage: /o [object name]");
        new str[64];
        if(cmdtext[4] != EOS) {
            for(new d; d < MAX_OBJ; d++)
            {
                if(strfind(Objects[d][oName],cmdtext[3],true) != -1)
                {
                    format(str,64,"%d - %s",Objects[d][oID],Objects[d][oName]);
                    SendClientMessage(playerid,0xE60005FF,str);
                }
            }
        }else{
            for(new d; d < MAX_OBJ; d++)
            {
                if(!strcmp(cmdtext[3],Objects[d][oName],false,1))
                {
                    format(str,64,"%d - %s",Objects[d][oID],Objects[d][oName]);
                    SendClientMessage(playerid,0xFFFFFFFF,str);
                }
            }
        }
        return 1;
    }
    return 0;
}



Re: /o(bject) list - MadeMan - 04.02.2011

pawn Код:
CMD:findfile(playerid,params[])
{
    new filename[64], search[64], msg[128];
    if(sscanf(params, "s[64]s[64]", filename, search)) return SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /findfile [filename] [search]");
    if(!fexist(filename)) return SendClientMessage(playerid, 0xEE0000FF, "File doesn't exist!");
    new File:handle = fopen(filename, io_read);
    while(fread(handle, msg))
    {
        if(strfind(msg, search, true) != -1)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, msg);
        }
    }
    fclose(handle);
    return 1;
}
If you have a file with object IDs, place it inside scriptfiles folder and use this command.


Re: /o(bject) list - Majataka - 04.02.2011

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
pawn Код:
CMD:findfile(playerid,params[])
{
    new filename[64], search[64], msg[128];
    if(sscanf(params, "s[64]s[64]", filename, search)) return SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /findfile [filename] [search]");
    if(!fexist(filename)) return SendClientMessage(playerid, 0xEE0000FF, "File doesn't exist!");
    new File:handle = fopen(filename, io_read);
    while(fread(handle, msg))
    {
        if(strfind(msg, search, true) != -1)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, msg);
        }
    }
    fclose(handle);
    return 1;
}
If you have a file with object IDs, place it inside scriptfiles folder and use this command.
Thank you
Edit: Where should I put the code you sent here? P: Oh and I made a "object.txt" with text in this format "OBJECT ID - Desc."


Re: /o(bject) list - MadeMan - 04.02.2011

You can use dcmd, easier to set up if you have other commands.

pawn Код:
dcmd_findfile(playerid, params[])
{
    new filename[64], search[64], msg[128];
    if(sscanf(params, "s[64]s[64]", filename, search)) return SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /findfile [filename] [search]");
    if(!fexist(filename)) return SendClientMessage(playerid, 0xEE0000FF, "File doesn't exist!");
    new File:handle = fopen(filename, io_read);
    while(fread(handle, msg))
    {
        if(strfind(msg, search, true) != -1)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, msg);
        }
    }
    fclose(handle);
    return 1;
}
Under OnPlayerCommandText

pawn Код:
dcmd(findfile,8,cmdtext);
Also add this line to your script

pawn Код:
#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
And then you can use /findfile object.txt ball


Re: /o(bject) list - Majataka - 04.02.2011

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
You can use dcmd, easier to set up if you have other commands.

pawn Код:
dcmd_findfile(playerid, params[])
{
    new filename[64], search[64], msg[128];
    if(sscanf(params, "s[64]s[64]", filename, search)) return SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /findfile [filename] [search]");
    if(!fexist(filename)) return SendClientMessage(playerid, 0xEE0000FF, "File doesn't exist!");
    new File:handle = fopen(filename, io_read);
    while(fread(handle, msg))
    {
        if(strfind(msg, search, true) != -1)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, msg);
        }
    }
    fclose(handle);
    return 1;
}
Under OnPlayerCommandText

pawn Код:
dcmd(findfile,8,cmdtext);
Also add this line to your script

pawn Код:
#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
And then you can use /findfile object.txt ball
I get I:\Programfiler\Rockstar Games\GTA San Andreas\Server\gamemodes\Majatacker.pwn(1426) : error 017: undefined symbol "sscanf"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
After I compile. I have the sscanf2.inc in Pawno/include and sscanf.so in plugins

I can't find the problem D:


Re: /o(bject) list - MadeMan - 04.02.2011

Add this to script

pawn Код:
#include <sscanf2>



Re: /o(bject) list - Majataka - 04.02.2011

Thank you so much! Works now