-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.pwn
137 lines (123 loc) · 3.69 KB
/
tests.pwn
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <a_samp>
#include <core>
#include <float>
#include <dialogs>
#pragma tabsize 0
main()
{
print("\n----------------------------------");
print(" Bare Script\n");
print("----------------------------------\n");
}
public OnPlayerConnect(playerid)
{
GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
return 1;
}
const Dialog_3 = 1;
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/dialog-1", true) == 0) {
ShowDialog(playerid, Dialog_1);
return 1;
}
else if(strcmp(cmd, "/dialog-2", true) == 0) {
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
ShowDialog(playerid, Dialog_2, DIALOG_STYLE_MSGBOX, "Dialog_2", "Hi %s!\nHow are you?", "button1", "button2", name);
return 1;
}
else if(strcmp(cmd, "/dialog-3", true) == 0) {
new name[MAX_PLAYER_NAME], info[21 + MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(info, sizeof(info), "Hi %s!\nHow are you?", name);
ShowPlayerDialog(playerid, Dialog_3, DIALOG_STYLE_MSGBOX, "Dialog_3", info, "button1", "button2");
return 1;
}
return 0;
}
CreateDialog:Dialog_1(playerid, style, caption[], info[], button1[], button2[])
{
style = DIALOG_STYLE_MSGBOX;
caption = "Dialog_1";
button1 = "button1";
button2 = "button2";
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(info, sizeof(info), "Hi %s!\nHow are you?", name);
}
Dialog:Dialog_1(playerid, response, listitem, inputtext[])
{
SendClientMessage(playerid, -1, response ? ("Dialog_1 response: You clicked at button 1") : ("Dialog_1 response: You clicked at button 0"));
return true;
}
Dialog:Dialog_2(playerid, response, listitem, inputtext[])
{
SendClientMessage(playerid, -1, response ? ("Dialog_2 response: You clicked at button 1") : ("Dialog_2 response: You clicked at button 0"));
return true;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == Dialog_3)
{
SendClientMessage(playerid, -1, response ? ("Dialog_3 OnDialogResponse: You clicked at button 1") : ("Dialog_3 OnDialogResponse: You clicked at button 0"));
return true;
}
return true;
}
public OnPlayerSpawn(playerid)
{
SetPlayerInterior(playerid,0);
TogglePlayerClock(playerid,0);
SendClientMessage(playerid, -1, "To test this include use:");
SendClientMessage(playerid, -1, "{0000FF}/dialog-1{FFFFFF} to test the pre-created dialog.");
SendClientMessage(playerid, -1, "{0000FF}/dialog-2{FFFFFF} to test the normal dialog, using ShowDialog.");
SendClientMessage(playerid, -1, "{0000FF}/dialog-3{FFFFFF} to test the normal dialog, using ShowPlayerDialog.");
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
SetupPlayerForClassSelection(playerid)
{
SetPlayerInterior(playerid,14);
SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
SetPlayerFacingAngle(playerid, 270.0);
SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}
public OnPlayerRequestClass(playerid, classid)
{
SetupPlayerForClassSelection(playerid);
return 1;
}
public OnGameModeInit()
{
SetGameModeText("Bare Script");
ShowPlayerMarkers(1);
ShowNameTags(1);
AllowAdminTeleport(1);
AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}