A question for mysql
#1

Is there any way for my /deleteorg command if players that are offline and their organization gets deleted they get auto orgless. Ok this it what i mean.

* Jack joins Grove Street Families (orgid 1)
* Jack quits the server
* Tanush uses /deleteorg 1 Inactive (/deleteorg [orgid] [reason])
* Jack automatically gets -255 for the organization he is in (-255 = orgless)


I just want that if i delete a organization, people that is in that orgid and is offline will get auto orgless. Everything is fine, i only need to add 1 thing that is make the person orgless if he is offline while the organization gets deleted
pawn Код:
CMD:deleteorg(playerid,params[])
{
    new orgid;
    if(!IsPlayerAdmin(playerid)) return 0;
    if(sscanf(params,"is[128",orgid,message)) return SCM(playerid,grey,"USAGE: /deleteorg [orgid] [Reason]");
    if(!DoesOrgExist(orgid))return SCM(playerid,red,"ERROR: This Organization ID is not used.");
    GetPlayerName(playerid,Nam,sizeof(Nam));
    DestroyDynamic3DTextLabel(OrgInfo[orgid][orglabel]);
    DestroyDynamicCP(OrgInfo[orgid][CP]);
    DestroyVehicle(OrgInfo[orgid][Car1]);
    DestroyVehicle(OrgInfo[orgid][Car2]);
    DestroyVehicle(OrgInfo[orgid][Car3]);
    DestroyVehicle(OrgInfo[orgid][Car4]);
    DestroyVehicle(OrgInfo[orgid][Car5]);
    DestroyVehicle(OrgInfo[orgid][Car6]);
    DestroyVehicle(OrgInfo[orgid][Car7]);
    DestroyVehicle(OrgInfo[orgid][Car8]);
    format(str,sizeof(str),"Administrator %s has deleted %s (orgid %d) for %s",Nam,OrgInfo[orgid][Orgname],orgid,message);
    SendClientMessageToAll(COLOR_LIGHTBLUE,str);
    format(str,sizeof(str),"DELETE FROM orgs WHERE Orgid = '%d'",orgid);
    mysql_query(str);
    mysql_free_result();
    foreach(Player,i)
    {
        if(orgid == PlayerData[i][Member])
        {
            PlayerData[i][Member] = -255;
            PlayerData[i][Leader] = 0;
            PlayerData[i][Genre] = 0;
            SetPlayerSkin(i,26);
            SetPlayerColor(i,-1);
            format(str,sizeof(str),"[Org Info]: You are now a civilian because your org has been deleted");
            SCM(i,COLOR_YELLOW,str);
        }
    }
    return 1;
}
Reply
#2

Delete TABLE FROM `Orgs` WHERE `Orgid` = '%d'?
Reply
#3

Ok example i create orgid 1 as grove and an rcon admin deletes orgid 1, how can i make whoever has Member = 1 and is offline will be changed to Member = -255.

SELECT * FROM accounts WHERE Member = %d
Reply
#4

Quote:
Originally Posted by Snowman12
Посмотреть сообщение
Delete TABLE FROM `Orgs` WHERE `Orgid` = '%d'?
http://www.w3schools.com/sql/sql_delete.asp his syntax is correct.

OT: How is the org saved? Is the org saved in the player tables, if so use
Код:
UPDATE tablename SET .... WHERE orgid = -255
Reply
#5

Well actually this is what i mean, for player saving the table is: accounts,
for orgs its: orgs.

Ok i want that if a faction gets deleted and members that are in the faction and is offline, the members that are offline while the organization gets deleted in game it will cause all members that are also offline that is in the organization ID to be orgless (-255) so UPDATE accounts SET Member = -255
Reply
#6

nvm.
Reply
#7

pawn Код:
new query[256];
format(query,256,"UPDATE `accounts` SET `Member` = '-255' WHERE `Member` = '%d'",orgid);//orgid = organization which RCON admin typed into command.
mysql_query(query);
Should work. Also once you delete from Table I don't think you need mysql_free_result();
Reply
#8

thanks Dimi, repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)