SA-MP Forums Archive
help me - 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: help me (/showthread.php?tid=598265)



help me - N0FeaR - 10.01.2016

i trying make change chatstyle cmd but when i change chatstyle wont update it in my mysql database what might be the problme?


PHP код:
}
CMD:chatstyle(playeridparams[])
{
    new 
aimidszQuery[128];
    if(
sscanf(params"i"aimid)) SendClientMessage(playeridCOLOR_GREY"USAGE: /chatstyle [0-8]");
    else
    {
        if (
PlayerCuffed[playerid] >= 1) return SendClientMessageEx(playeridCOLOR_WHITE"You cannot use this while cuffed!");
        if (
PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playeridCOLOR_WHITE"You cannot use this now!");
        if (
PlayerInfo[playerid][pHospital] > 0) return SendClientMessageEx(playeridCOLOR_WHITE"You cannot use this while in hospital");
        if (
GetPVarInt(playerid"Injured")) return SendClientMessageEx(playeridCOLOR_WHITE"You cannot use this while dead!");
        switch(
aimid)
        {
            case 
0:
            {
                
DeletePVar(playerid,"ChatStyle");
                
SendClientMessage(playerid,COLOR_WHITE,"Chatstyle removed.");
            }
            case 
.. 8:
            {
                
format(szQuerysizeof(szQuery), "UPDATE `accounts` SET `ChatStyle`=%d WHERE `ChatStyle` = '%d'"PlayerInfo[aimid][pChatStyle]);
                
mysql_function_query(MainPipelineszQueryfalse"OnQueryFinish""ii"SENDDATA_THREADplayerid);
                
SetPVarInt(playerid"ChatStyle"aimid);
                
SendClientMessage(playerid,COLOR_WHITE,"Chatstyle set.");
            }
            default: 
SendClientMessage(playeridCOLOR_GREY"USAGE: /chatstyle [0-8]");
        }
    }
    return 
1;




Re: help me - OwlIT - 10.01.2016

Well you have forgotten to update the pChatStyle variable and you have inserted in the 'playerid' parameter 'aimid'. Put this before the query:
Код:
PlayerInfo[playerid][pChatStyle] = aimid;



Re: help me - N0FeaR - 10.01.2016

Quote:
Originally Posted by OwlIT
Посмотреть сообщение
Well you have forgotten to update the pChatStyle variable and you have inserted in the 'playerid' parameter 'aimid'. Put this before the query:
Код:
PlayerInfo[playerid][pChatStyle] = aimid;
Still same problem.


Re: help me - jlalt - 10.01.2016

Change:
PHP код:
format(szQuerysizeof(szQuery), "UPDATE `accounts` SET `ChatStyle`=%d WHERE `ChatStyle` = '%d'"PlayerInfo[aimid][pChatStyle]); 
with
PHP код:
format(szQuerysizeof(szQuery), "UPDATE `accounts` SET `ChatStyle`= '%d' WHERE `ChatStyle` = '%d'"aimidPlayerInfo[playerid][pChatStyle]); 
You were using two %d but just telling one of them what should it be so my code should work :c


Re: help me - PrO.GameR - 10.01.2016

`ChatStyle` = '%d'"
Are you seriously using Chatstyle as the where clause ? Do you know what that will do ? Lemme show you

I use chatstyle, set my chatstyle to 3, You having chatstyle 3 use it, change yours to 5, that actually will change everyone that have/had chatstyle 3 to 5, including me, your where clause should be
`ID` = %d, %d pointing to PlayerInfo[aimid][SQLID] or whatever you saved SQLID into.

PHP код:
                format(szQuerysizeof(szQuery), "UPDATE `accounts` SET `ChatStyle`=%d WHERE `ID` = %d"aimid,PlayerInfo[playerid][SQLID]); 
Honestly this feels a lot like copy-pasted now not working kind of topic, Where the hell did you take this from ? PlayerInfo[aimid][pChatStyle] << What is this supposed to mean ? it should be playerid not aimid.