forked from CamxxCore/iFruitAddon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExampleScript.cs
91 lines (76 loc) · 2.68 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using GTA;
using GTA.Math;
using GTA.Native;
using iFruitAddon;
namespace ExampleScript
{
public class ExampleScript : Script
{
CustomiFruit ifruit;
public ExampleScript()
{
ifruit = new CustomiFruit()
{
CenterButtonColor = System.Drawing.Color.Orange,
LeftButtonColor = System.Drawing.Color.LimeGreen,
RightButtonColor = System.Drawing.Color.Purple,
CenterButtonIcon = SoftKeyIcon.Fire,
LeftButtonIcon = SoftKeyIcon.Police,
RightButtonIcon = SoftKeyIcon.Website
};
ifruit.SetWallpaper(new Wallpaper("char_facebook"));
//or..
ifruit.SetWallpaper(Wallpaper.BadgerDefault);
var contact = new iFruitContact("Spawn Adder", 19);
contact.Answered += Contact_Answered;
contact.DialTimeout = 8000;
contact.Active = true;
//set custom icons by instantiating the ContactIcon class
contact.Icon = new ContactIcon("char_sasquatch");
ifruit.Contacts.Add(contact);
contact = new iFruitContact("Teleport to Waypoint", 20);
contact.Answered += (s) => Scripts.TeleportToWaypoint();
contact.DialTimeout = 0;
contact.Icon = ContactIcon.Target;
ifruit.Contacts.Add(contact);
Tick += OnTick;
}
private void Contact_Answered(iFruitContact contact)
{
Scripts.SpawnVehicle("ADDER");
UI.Notify("Your Adder has been delivered!");
}
void OnTick(object sender, EventArgs e)
{
ifruit.Update();
}
protected override void Dispose(bool A_0)
{
ifruit.Contacts.ForEach(x => x.EndCall());
base.Dispose(A_0);
}
}
public static class Scripts
{
public static void TeleportToWaypoint()
{
Blip wpBlip = new Blip(Function.Call<int>(Hash.GET_FIRST_BLIP_INFO_ID, 8));
if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE))
{
GTA.Math.Vector3 wpVec = Function.Call<GTA.Math.Vector3>(Hash.GET_BLIP_COORDS, wpBlip);
Game.Player.Character.Position = wpVec;
}
else
{
UI.ShowSubtitle("Waypoint not active.");
}
}
public static void SpawnVehicle(string vehiclename)
{
Model model = new Model(vehiclename);
model.Request(1000);
World.CreateVehicle(model, Game.Player.Character.Position + Game.Player.Character.ForwardVector * 5);
}
}
}