[in game error] sscanf problems
#1

Hi whenever i use my commands is says that i am typing it wrong? below here you can see the commands that are not working!


pawn Код:
CMD:goto(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");
    else if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
    else
    {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    SetPlayerPos(playerid, x+1, y+1, z);
    }
    return 1;
}
CMD:gethere(playerid,params[])
{
    new targetid, Float:x, Float:y, Float:z;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /gethere [id]");
    if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
    SetPlayerPos(targetid, x+1, y+1, z);
    return 1;
}
CMD:afix(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
    }
    else SendClientMessage(playerid, COLOR_RED, "You must be an admin to use this command");
    return 1;
}
CMD:setfaction(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] <= 5)
    {
    new otherplayerid;
    new faction;
    new pName[MAX_PLAYER_NAME], gName[MAX_PLAYER_NAME];
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "u", otherplayerid, faction)) return SendClientMessage(playerid, COLOR_RED, "Use /setfaction [playerid/name] [faction number 1 - 11]");
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(otherplayerid, gName, MAX_PLAYER_NAME);
    SendClientMessage(otherplayerid, COLOR_GREEN, " ** Admin %s has set your faction to %s", pName, faction);
    SendClientMessage(playerid, COLOR_GREEN, " ** You have set player %s faction to %s", gName, faction);
    PlayerInfo[otherplayerid][gTeam] = faction;
    }
    else SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 5 admin to do that!");
    return 1;
}
CMD:givemoney(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        new otherplayerid;
        new money;
        if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
        if(sscanf(params, "u", otherplayerid, money)) return SendClientMessage(playerid, COLOR_RED, "Use /givemoney [playerid/name] [amount of money]");
        SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some money");
        SendClientMessage(playerid, COLOR_GREEN, " ** You have been given money from a admin!");
        GivePlayerMoney(otherplayerid, money);
    }
    else return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 2 admin to do that!");
    return 1;

}
CMD:sethp(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new otherplayerid;
        new health;
        if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
        if(sscanf(params, "u", otherplayerid, health)) return SendClientMessage(playerid, COLOR_RED, "Use /sethp [playerid/name] [amount of health]");
        SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some health");
        SendClientMessage(playerid, COLOR_GREEN, " ** You have been healed by a admin!");
        SetPlayerHealth(otherplayerid, health);
    }
    else return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 1 admin to do that!");
    return 1;
}
CMD:setarmour(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new otherplayerid;
        new armour;
        if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
        if(sscanf(params, "u", otherplayerid, armour)) return SendClientMessage(playerid, COLOR_RED, "Use /setarmour [playerid/name] [amount of armour]");
        SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some armour");
        SendClientMessage(playerid, COLOR_GREEN, " ** You have been given armour by a admin!");
        SetPlayerArmour(otherplayerid, armour);
    }
    else return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 1 admin to do that!");
    return 1;
}
Reply
#2

Try this
pawn Код:
CMD:goto(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");
    if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");

    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    SetPlayerPos(playerid, x+1, y+1, z);
    return 1;
}
CMD:gethere(playerid,params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /gethere [id]");
   
    new Float:x, Float:y, Float:z;
    if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
    SetPlayerPos(targetid, x+1, y+1, z);
    return 1;
}
CMD:afix(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "You must be an admin to use this command");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");

    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
    return 1;
}
CMD:setfaction(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 5)
        return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 5 admin to do that!");

    new otherplayerid, faction;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "ud", otherplayerid, faction)) return SendClientMessage(playerid, COLOR_RED, "Use /setfaction [playerid/name] [faction number 1 - 11]");

    new pName[MAX_PLAYER_NAME], gName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(otherplayerid, gName, MAX_PLAYER_NAME);
    SendClientMessage(otherplayerid, COLOR_GREEN, " ** Admin %s has set your faction to %s", pName, faction);
    SendClientMessage(playerid, COLOR_GREEN, " ** You have set player %s faction to %s", gName, faction);
    PlayerInfo[otherplayerid][gTeam] = faction;
    return 1;
}
CMD:givemoney(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2)
        return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 2 admin to do that!");

    new otherplayerid, money;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "ud", otherplayerid, money)) return SendClientMessage(playerid, COLOR_RED, "Use /givemoney [playerid/name] [amount of money]");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some money");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have been given money from a admin!");
    GivePlayerMoney(otherplayerid, money);
    return 1;
}

CMD:sethp(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 1 admin to do that!");

    new otherplayerid, Float:health;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "uf", otherplayerid, health)) return SendClientMessage(playerid, COLOR_RED, "Use /sethp [playerid/name] [amount of health]");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some health");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have been healed by a admin!");
    SetPlayerHealth(otherplayerid, health);
    return 1;
}
CMD:setarmour(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 1 admin to do that!");

    new otherplayerid, Float:armour;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "uf", otherplayerid, armour)) return SendClientMessage(playerid, COLOR_RED, "Use /setarmour [playerid/name] [amount of armour]");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some armour");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have been given armour by a admin!");
    SetPlayerArmour(otherplayerid, armour);
    return 1;
}
Reply
#3

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Try this
pawn Код:
CMD:goto(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");
    if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");

    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    SetPlayerPos(playerid, x+1, y+1, z);
    return 1;
}
CMD:gethere(playerid,params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /gethere [id]");
   
    new Float:x, Float:y, Float:z;
    if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
    SetPlayerPos(targetid, x+1, y+1, z);
    return 1;
}
CMD:afix(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "You must be an admin to use this command");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");

    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
    return 1;
}
CMD:setfaction(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 5)
        return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 5 admin to do that!");

    new otherplayerid, faction;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "ud", otherplayerid, faction)) return SendClientMessage(playerid, COLOR_RED, "Use /setfaction [playerid/name] [faction number 1 - 11]");

    new pName[MAX_PLAYER_NAME], gName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(otherplayerid, gName, MAX_PLAYER_NAME);
    SendClientMessage(otherplayerid, COLOR_GREEN, " ** Admin %s has set your faction to %s", pName, faction);
    SendClientMessage(playerid, COLOR_GREEN, " ** You have set player %s faction to %s", gName, faction);
    PlayerInfo[otherplayerid][gTeam] = faction;
    return 1;
}
CMD:givemoney(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2)
        return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 2 admin to do that!");

    new otherplayerid, money;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "ud", otherplayerid, money)) return SendClientMessage(playerid, COLOR_RED, "Use /givemoney [playerid/name] [amount of money]");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some money");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have been given money from a admin!");
    GivePlayerMoney(otherplayerid, money);
    return 1;
}

CMD:sethp(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 1 admin to do that!");

    new otherplayerid, Float:health;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "uf", otherplayerid, health)) return SendClientMessage(playerid, COLOR_RED, "Use /sethp [playerid/name] [amount of health]");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some health");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have been healed by a admin!");
    SetPlayerHealth(otherplayerid, health);
    return 1;
}
CMD:setarmour(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, " ** You need to be a level 1 admin to do that!");

    new otherplayerid, Float:armour;
    if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_RED, " ** They are not online!");
    if(sscanf(params, "uf", otherplayerid, armour)) return SendClientMessage(playerid, COLOR_RED, "Use /setarmour [playerid/name] [amount of armour]");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have given that player some armour");
    SendClientMessage(playerid, COLOR_GREEN, " ** You have been given armour by a admin!");
    SetPlayerArmour(otherplayerid, armour);
    return 1;
}
Sorry i still get the exact same error saying how i should properly use the command
Reply
#4

What's your sscanf version ?
Reply
#5

This is what i am getting when the pkugin is loading, not sure what exact version it is though, sorry.

pawn Код:
[23:11:25]  ===============================

[23:11:25]       sscanf plugin loaded.    

[23:11:25]    (c) 2009 Alex "******" Cole

[23:11:25]    0.3d-R2 500 Players "dnee"

[23:11:25]  ===============================
Reply
#6

http://forum.sa-mp.com/showthread.ph...ghlight=sscanf

Are you using
pawn Код:
#include <sscanf>
or
pawn Код:
#include <sscanf2>
Reply
#7

im using sscanf2
Reply
#8

Can you post the error code your getting please.
Reply
#9

Quote:
Originally Posted by Oscii
Посмотреть сообщение
Can you post the error code your getting please.
i've already said. im getting the error in my code about me using the command wrong. not a cmpile error.
Reply
#10

oh. i see.

What does it say when you type the cmd ingame.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)