Delete contracts

Messages
2
Likes
1
#1
I am currently creating custom commands tailored to our server gameplay.
While I have figured out how to work with currencies, i am having more trouble with contracts. Does anyone know how you can delete a contract?
 

Kirthos

Iron
Mod Dev
Messages
137
Likes
65
#2
I didn't test it but I suppose something like that will work

C#:
        [ChatCommand("Delete a contract by name", ChatAuthorizationLevel.Admin)]
        public static void DeleteContract(User user, string contractName)
        {
            EconomyManager.Contracts.DestroyContract(EconomyManager.Contracts.Contracts.First(x => x.Name == contractName).ContractID);
        }
 
OP
OP
K
Messages
2
Likes
1
#3
Thank you. That was what i was looking for.
I thought i had tried that before but i must have done something wrong. Anyway, i got it working now.

C#:
    [ChatCommand("Clear all accepted contracts")]
    public static void ClearMyAcceptedContracts(User user)
    {
        foreach(Contract contract in user.AcceptedContracts)
        {
            EconomyManager.Contracts.DestroyContract(contract.ContractID);
        }
    }
 
Top Bottom