SA-MP Forums Archive
Why wont this work? - 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)
+--- Thread: Why wont this work? (/showthread.php?tid=283117)



Why wont this work? - Dokins - 13.09.2011

pawn Код:
CMD:setfactionent(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(AdminLevel[playerid] < 4) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
    if(isnull(params)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /setfactionent [factionid]");
    new factionid = strval(params);
    new id = MySQL_GetValue(FactionSQLID[id], "id", "factions");
   
    new Float: x, Float: y, Float: z;
    GetPlayerPos(playerid, x, y, z);
   
    FactionEntX[factionid] = x;
    FactionEntY[factionid] = y;
    FactionEntZ[factionid] = z;
    CreateDynamicPickup(1318, 23, FactionEntX[factionid], FactionEntY[factionid], FactionEntZ[factionid], 0, -1, -1, 100);

    MySQL_SetFloat(FactionSQLID[factionid], "FactionEntX", x, "factions");
    MySQL_SetFloat(FactionSQLID[factionid], "FactionEntY", y, "factions");
    MySQL_SetFloat(FactionSQLID[factionid], "FactionEntZ", z, "factions");
    new string[128];
    format(string, sizeof(string), "You have set %s's entrance", FactionName[factionid]);
    SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
    return 1;
}
I cannot think of a single reason as to why this wont work and yes, the MySQL_SetFloat Works.

Thanks in advance.


Re: Why wont this work? - =WoR=Varth - 13.09.2011

Explain "Won't work".


Re: Why wont this work? - brett7 - 13.09.2011

Your missing a scanf aren't you?
Код:
if(sscanf(params, "u", id))
    {
        SendClientMessage(playerid, 0xFF0000FF, "Usage: /setfactionent [factionid]");
        return 1;
    }



Re: Why wont this work? - =WoR=Varth - 13.09.2011

Quote:
Originally Posted by brett7
Посмотреть сообщение
Your missing a scanf aren't you?
Код:
if(sscanf(params, "u", id))
    {
        SendClientMessage(playerid, 0xFF0000FF, "Usage: /setfactionent [factionid]");
        return 1;
    }
He didn't use sscanf.
pawn Код:
if(isnull(params)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /setfactionent [factionid]");
    new factionid = strval(params);



Re: Why wont this work? - Dokins - 13.09.2011

AS in, the command In-game will not work, it returns the function success = 0 as in, it says Command not recognized.


Re: Why wont this work? - FireCat - 13.09.2011

Show me MYSQL_SetFloat.


Re: Why wont this work? - Dokins - 13.09.2011

pawn Код:
MySQL_SetFloat(sqlid, fieldname[], Float:value, tablename[])
{
    new query[256];
    format(query, sizeof(query), "UPDATE %s SET %s = %f WHERE id = %d LIMIT 1", tablename, fieldname, value, sqlid);
    return mysql_query(query);
}
There ya go.


Re: Why wont this work? - Dokins - 13.09.2011

Any issue there?


Re: Why wont this work? - FireCat - 14.09.2011

1st of all use sscanf.
If you want, I'll re-write this code using sscanf.

2nd of all don't you use a variable to create the pickup?

pawn Код:
CMD:setfactionent(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(AdminLevel[playerid] < 4) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
    if(isnull(params)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /setfactionent [factionid]");
    new factionid = strval(params);
    new id = MySQL_GetValue(FactionSQLID[id], "id", "factions");
   
    new Float: x, Float: y, Float: z;
    GetPlayerPos(playerid, x, y, z);
   
    FactionEntX[factionid] = x;
    FactionEntY[factionid] = y;
    FactionEntZ[factionid] = z;
    YOURVARHERE = CreateDynamicPickup(1318, 23, FactionEntX[factionid], FactionEntY[factionid], FactionEntZ[factionid], 0, -1, -1, 100);

    MySQL_SetFloat(FactionSQLID[factionid], "FactionEntX", x, "factions");
    MySQL_SetFloat(FactionSQLID[factionid], "FactionEntY", y, "factions");
    MySQL_SetFloat(FactionSQLID[factionid], "FactionEntZ", z, "factions");
    new string[128];
    format(string, sizeof(string), "You have set %s's entrance", FactionName[factionid]);
    SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
    return 1;
}



Re: Why wont this work? - Dokins - 14.09.2011

I've used sscanf before, it didnt really make a difference, I'll try again and yeah there is a variable FactionPickup, but I dont see how thats relevant?

Thank you very much, i'll let you know if this works.