sscanf help
#1

//Edit: Fixed the old problem -- Onto a new one..

Why isn't this working? The parameters work correctly, and as a seperate command, the icon gets added to the file - but it doesn't seem to be working all-together for some reason.

pawn Код:
COMMAND:add(playerid, params[])
{
    new
        parameters[35],
        mapicon_id,
        mapicon_color,
        Float:MapIconX,
        Float:MapIconY,
        Float:MapIconZ,
        vModel,
        Float:VX,
        Float:VY,
        Float:VZ,
        Float:VA,
        vColor1,
        vColor2;

    if(sscanf(params, "s[35]", parameters)) {
        SendClientMessage(playerid, c_white, "[USAGE] /Add [Parameters]");
        SendClientMessage(playerid, c_orange, "[PARAMETERS] MapIcon, Vehicle, Pickup, 3DTextLabel");
        return 1;
    }
   
    if(strcmp(parameters, "MapIcon", true) == 0) { //Created by [L3th4l]
        new MType, Float:MX, Float:MY, Float:MZ, MColor;
        if(unformat(params, "ih", MType, MColor)) return SendClientMessage(playerid, c_white,"[USAGE] /AddIcon <Icon ID> <Icon Color>");
        GetPlayerPos(playerid, MX, MY, MZ);

        AddMapIconToFile(ICON_FILE_NAME, MX, MY, MZ, MType, MColor);

        for(new PID; PID < MAX_PLAYERS; PID++) if(IsPlayerConnected(PID))
        {
            CreateDynamicMapIcon(MX, MY, MZ, MType, MColor, -1, -1, -1, 100.0);
        }
        /*if(sscanf(params, "ih", mapicon_id, mapicon_color)) {
            SendClientMessage(playerid, c_white, "[USAGE] /Add MapIcon [Icon ID] [Icon Colour]");
            SendClientMessage(playerid, c_orange, "[FUNCTION] Creates a permanent Map Icon viewable by all players at your position.");
            return 1;
        }
        GetPlayerPos(playerid, MapIconX, MapIconY, MapIconZ);
        AddMapIconToFile(ICON_FILE_NAME, MapIconX, MapIconY, MapIconZ, mapicon_id, mapicon_color);
        for(new PID; PID < MAX_PLAYERS; PID++) if(IsPlayerConnected(PID))
        {
            CreateDynamicMapIcon(MapIconX, MapIconY, MapIconZ, mapicon_id, mapicon_color, -1, -1, -1, 100.0);
        }*/

        printf("[+] Pickup created at %f, %f, %f | ID: %d | Color: %h", MapIconX, MapIconY, MapIconZ, mapicon_id, mapicon_color);
        return 1;
    }
   
    else if(strcmp(parameters, "Vehicle", true) == 0) {
        if(IsPlayerInAnyVehicle(playerid)) {
            GetPlayerPos(playerid, VX, VY, VZ);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), VA);
            vModel = GetVehicleModel(GetPlayerVehicleID(playerid));
            GetVehicleColor(GetPlayerVehicleID(playerid), vColor1, vColor2);
            AddVehicleToFile(VEHICLE_FILE_NAME, VX, VY, VZ, VA, vModel, vColor1, vColor2);
            printf("[+] Vehicle created at %f, %f, %f | Model: %d | Color1: %d, Color2: %d", VX, VY, VZ, vColor1, vColor2);
            return 1;
        }
    }
    return 1;
}
Command that works:

pawn Код:
CMD:addicon(playerid, params[])
{
        new MType, Float:MX, Float:MY, Float:MZ, MColor;
        if(unformat(params, "ih", MType, MColor)) return SendClientMessage(playerid, c_white,"[USAGE] /AddIcon <Icon ID> <Icon Color>");
        GetPlayerPos(playerid, MX, MY, MZ);

        AddMapIconToFile(ICON_FILE_NAME, MX, MY, MZ, MType, MColor);

        for(new PID; PID < MAX_PLAYERS; PID++) if(IsPlayerConnected(PID))
        {
            CreateDynamicMapIcon(MX, MY, MZ, MType, MColor, -1, -1, -1, 100.0);
        }
        return 1;
}
Reply
#2

I'm going to go ahead and bump this, considering this topic is on the third page now and it's sure nobody will look at it.

Still requesting help guys, as I don't know what's wrong.
Reply
#3

Whats the "unformat"? Sscanf function? If not, you cant use it along with sscanf as far as I know. Not in the same callback at least.

This forum requires that you wait 120 seconds between posts. Please try again in 56 seconds.
Reply
#4

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
Whats the "unformat"? Sscanf function? If not, you cant use it along with sscanf as far as I know. Not in the same callback at least.

This forum requires that you wait 120 seconds between posts. Please try again in 56 seconds.
I'm assuming it is a sscanf function, yes.
Reply
#5

Bumping once again -- I REALLY need help with this.
Reply
#6

I take a look at official sscanf thread about "Unformat" and then come back.
P.S, Why dont you just use if(sscanf(params, ... ?? a lot easier and efficient way

EDIT: I have took a look at sscanf thread. There is an "unformat" action indeed. I will take a look at ur script

EDIT II: I am sorry but I do not see anything wrong here. Please wait for a higher leveled scripter to help ya out bro
Reply
#7

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
I take a look at official sscanf thread about "Unformat" and then come back.
P.S, Why dont you just use if(sscanf(params, ... ?? a lot easier and efficient way

EDIT: I have took a look at sscanf thread. There is an "unformat" action indeed. I will take a look at ur script

EDIT II: I am sorry but I do not see anything wrong here. Please wait for a higher leveled scripter to help ya out bro
Right, thank you for trying. I can't figure out anything that's wrong here. Still requesting help, if possible.. I've been trying to figure this out for two days now, and can't seem to find anything wrong.
Reply
#8

What is exactly what you're trying to do? as far as I understand it from this topic, you have a command that creates either MapIcons, vehicles, pickups or 3dtextlabels. If yes why did you create a seperate command to create an icon?
Reply
#9

Quote:
Originally Posted by playbox12
Посмотреть сообщение
What is exactly what you're trying to do? as far as I understand it from this topic, you have a command that creates either MapIcons, vehicles, pickups or 3dtextlabels. If yes why did you create a seperate command to create an icon?
They were all originally seperate commands (/addpickup, /addmapicon, /savevehicle, /add3dlabel), I'm trying to put them all into one command (/add pickup/mapicon/vehicle/3dtextlabel ***)
Reply
#10

So it does write to the file and it does display it, so what is not working?

You mean, everything together the big command does not work correctly, but everything seperated does?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)