SA-MP Forums Archive
Trying to make this set Arrested = 1 for all ID's in table. - 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: Trying to make this set Arrested = 1 for all ID's in table. (/showthread.php?tid=502555)



Trying to make this set Arrested = 1 for all ID's in table that = PlayerSQLID - Dokins - 24.03.2014

This only sets the arrested = 1 for the last table it dealt with.

pawn Код:
format(query, sizeof(query), "UPDATE `arecords` SET arrested = 1 WHERE id = %d", PlayerArrests[giveplayerid][ar_id]);
    mysql_query(query);
pawn Код:
format(string, sizeof(string), "SELECT * FROM `arecords` WHERE `PSQLID`= %d AND `Arrested`=0", PlayerSQLID[giveplayerid]);
    mysql_query(string);
    mysql_store_result();
    new r_msg[500];

    new totaltime = 0;
    //while(mysql_fetch_row(r_msg, "|"))
    while(mysql_fetch_row(r_msg))
    {
        sscanf(r_msg, "p<|>e<iiiis[24]ii>", PlayerArrests[giveplayerid]);
        totaltime += PlayerArrests[giveplayerid][ar_ti]; //same here, you'll have to change it to the fieldname that says how long he should be arrested for THAT ONE crim
    }
Where it retrieves.

Could anyone assist me?


Re: Trying to make this set Arrested = 1 for all ID's in table. - Konstantinos - 24.03.2014

pawn Код:
mysql_query("UPDATE arecords SET arrested = 1");



Re: Trying to make this set Arrested = 1 for all ID's in table. - Dokins - 24.03.2014

It has to set it for the specific IDS, that's the problem. As in, where PlayerSQLID == playerid.


Re: Trying to make this set Arrested = 1 for all ID's in table. - newbienoob - 24.03.2014

Why just not setting it this way?
UPDATE `arecords` SET arrested = 1 WHERE player_name = %s
(i just changed id to player_name)


Re: Trying to make this set Arrested = 1 for all ID's in table. - Konstantinos - 24.03.2014

The code you had would update the table and set "arrested" to 1 to any field with "id" equal to the value of PlayerArrests[giveplayerid][ar_id]. In the title you wrote "Trying to make this set Arrested = 1 for all ID's in table." that's why I posted a query that sets any row (assuming each row has a different ID) to 1 but above you said that it has to set it to specific IDs so you confused me about what you really want. Would you mind to explain better?

EDIT: He got it fixed.


Re: Trying to make this set Arrested = 1 for all ID's in table. - Dokins - 24.03.2014

All SQLID's are relative to the playersqlid, so it shouldn't make a difference, really?

EDIT:

I'm really sorry Konstantinos, You're right I should have explained better.


The command, checks all arrest records for the playerid's SQLID. If the time > 0 and arrested = 0 then it adds all of the time together and (should but thats the problem) sets the arrested = 1. (Then sets jail pos etc)