-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathExampleScript.cs
70 lines (59 loc) · 2.6 KB
/
ExampleScript.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using GTA;
using iFruitAddon2;
public class iFruitAddon2Example : Script
{
readonly CustomiFruit _iFruit;
public iFruitAddon2Example()
{
// Custom phone creation
_iFruit = new CustomiFruit();
// Wallpaper customization
// Game phone wallpaper:
_iFruit.SetWallpaper(Wallpaper.Orange8Bit);
// Game texture wallpaper (ytd file)
// Warning: since we cannot choose the texture inside the texture dictionary, the game will take the texture that have the same name as the ytd file.
// ie: "prop_screen_dctl.ytd" file has a "prop_screen_dctl" texture inside it, so it will work.
_iFruit.SetWallpaper("prop_screen_dctl");
// Buttons customization
_iFruit.LeftButtonColor = System.Drawing.Color.LimeGreen;
_iFruit.CenterButtonColor = System.Drawing.Color.Orange;
_iFruit.RightButtonColor = System.Drawing.Color.Purple;
_iFruit.LeftButtonIcon = SoftKeyIcon.Police;
_iFruit.CenterButtonIcon = SoftKeyIcon.Fire;
_iFruit.RightButtonIcon = SoftKeyIcon.Website;
// New contact (wait 4 seconds (4000ms) before picking up the phone)
iFruitContact contactA = new iFruitContact("Test contact")
{
DialTimeout = 4000, // Delay before answering
Active = true, // true = the contact is available and will answer the phone
Icon = ContactIcon.Blank // Contact's icon
};
contactA.Answered += ContactAnswered; // Linking the Answered event with our function
_iFruit.Contacts.Add(contactA); // Add the contact to the phone
// New contact (wait 4 seconds before displaying "Busy...")
iFruitContact contactB = new iFruitContact("Test contact 2")
{
DialTimeout = 4000,
Active = false, // false = the contact is busy
Icon = ContactIcon.Blocked,
Bold = true // Set the contact name in bold
};
_iFruit.Contacts.Add(contactB);
Tick += OnTick;
}
// Tick Event
void OnTick(object sender, EventArgs e)
{
_iFruit.Update();
}
private void ContactAnswered(iFruitContact contact)
{
// The contact has answered, we can execute our code
GTA.UI.Notification.Show("The contact has answered.");
// We need to close the phone at a moment.
// We can close it as soon as the contact pick up calling _iFruit.Close().
// Here, we will close the phone in 5 seconds (5000ms).
_iFruit.Close(5000);
}
}