1
+ #include < a_samp>
2
+ #include < core>
3
+ #include < float>
4
+ #include < dialogs>
5
+
6
+ #pragma tabsize 0
7
+
8
+ main ()
9
+ {
10
+ print (" \n ----------------------------------" );
11
+ print (" Bare Script\n " );
12
+ print (" ----------------------------------\n " );
13
+ }
14
+
15
+ public OnPlayerConnect (playerid)
16
+ {
17
+ GameTextForPlayer (playerid," ~w~SA-MP: ~r~Bare Script" ,5000 ,5 );
18
+ return 1 ;
19
+ }
20
+ const Dialog_3 = 1 ;
21
+ public OnPlayerCommandText (playerid, cmdtext[])
22
+ {
23
+ new idx;
24
+ new cmd[256 ];
25
+
26
+ cmd = strtok (cmdtext, idx);
27
+
28
+ if (strcmp (cmd, " /dialog-1" , true ) == 0 ) {
29
+ ShowDialog (playerid, Dialog_1);
30
+ return 1 ;
31
+ }
32
+ else if (strcmp (cmd, " /dialog-2" , true ) == 0 ) {
33
+ new name[MAX_PLAYER_NAME];
34
+ GetPlayerName (playerid, name, sizeof (name));
35
+ ShowDialog (playerid, Dialog_2, DIALOG_STYLE_MSGBOX, " Dialog_2" , " Hi %s !\n How are you?" , " button1" , " button2" , name);
36
+ return 1 ;
37
+ }
38
+ else if (strcmp (cmd, " /dialog-3" , true ) == 0 ) {
39
+ new name[MAX_PLAYER_NAME], info[21 + MAX_PLAYER_NAME];
40
+ GetPlayerName (playerid, name, sizeof (name));
41
+ format (info, sizeof (info), " Hi %s !\n How are you?" , name);
42
+ ShowPlayerDialog (playerid, Dialog_3, DIALOG_STYLE_MSGBOX, " Dialog_3" , info, " button1" , " button2" );
43
+ return 1 ;
44
+ }
45
+
46
+ return 0 ;
47
+ }
48
+ CreateDialog: Dialog_1 (playerid, style, caption[], info[], button1[], button2[])
49
+ {
50
+ style = DIALOG_STYLE_MSGBOX;
51
+ caption = " Dialog_1" ;
52
+ button1 = " button1" ;
53
+ button2 = " button2" ;
54
+ new name[MAX_PLAYER_NAME];
55
+ GetPlayerName (playerid, name, sizeof (name));
56
+ format (info, sizeof (info), " Hi %s !\n How are you?" , name);
57
+ }
58
+ Dialog: Dialog_1 (playerid, dialogid, response, listitem, inputtext[])
59
+ {
60
+ SendClientMessage (playerid, - 1 , response ? " Dialog_1 response: You clicked at button 1" : " Dialog_1 response: You clicked at button 0" );
61
+ return true ;
62
+ }
63
+ Dialog: Dialog_2 (playerid, dialogid, response, listitem, inputtext[])
64
+ {
65
+ SendClientMessage (playerid, - 1 , response ? " Dialog_2 response: You clicked at button 1" : " Dialog_2 response: You clicked at button 0" );
66
+ return true ;
67
+ }
68
+ public OnDialogResponse (playerid, dialogid, response, listitem, inputtext[])
69
+ {
70
+ if (dialogid == Dialog_3)
71
+ {
72
+ SendClientMessage (playerid, - 1 , response ? " Dialog_3 OnDialogResponse: You clicked at button 1" : " Dialog_3 OnDialogResponse: You clicked at button 0" );
73
+ return true ;
74
+ }
75
+ return true ;
76
+ }
77
+ public OnPlayerSpawn (playerid)
78
+ {
79
+ SetPlayerInterior (playerid,0 );
80
+ TogglePlayerClock (playerid,0 );
81
+ SendClientMessage (playerid, - 1 , " To test this include use:" );
82
+ SendClientMessage (playerid, - 1 , " {0000FF}/dialog-1{FFFFFF} to test the pre-created dialog." );
83
+ SendClientMessage (playerid, - 1 , " {0000FF}/dialog-2{FFFFFF} to test the normal dialog, using ShowDialog." );
84
+ SendClientMessage (playerid, - 1 , " {0000FF}/dialog-3{FFFFFF} to test the normal dialog, using ShowPlayerDialog." );
85
+ return 1 ;
86
+ }
87
+
88
+ public OnPlayerDeath (playerid, killerid, reason)
89
+ {
90
+ return 1 ;
91
+ }
92
+
93
+ SetupPlayerForClassSelection (playerid)
94
+ {
95
+ SetPlayerInterior (playerid,14 );
96
+ SetPlayerPos (playerid,258 .4893 ,- 41 .4008 ,1002 .0234 );
97
+ SetPlayerFacingAngle (playerid, 270 .0 );
98
+ SetPlayerCameraPos (playerid,256 .0815 ,- 43 .0475 ,1004 .0234 );
99
+ SetPlayerCameraLookAt (playerid,258 .4893 ,- 41 .4008 ,1002 .0234 );
100
+ }
101
+
102
+ public OnPlayerRequestClass (playerid, classid)
103
+ {
104
+ SetupPlayerForClassSelection (playerid);
105
+ return 1 ;
106
+ }
107
+
108
+ public OnGameModeInit ()
109
+ {
110
+ SetGameModeText (" Bare Script" );
111
+ ShowPlayerMarkers (1 );
112
+ ShowNameTags (1 );
113
+ AllowAdminTeleport (1 );
114
+
115
+ AddPlayerClass (265 ,1958 .3783 ,1343 .1572 ,15 .3746 ,270 .1425 ,0 ,0 ,0 ,0 ,- 1 ,- 1 );
116
+
117
+ return 1 ;
118
+ }
119
+
120
+ strtok (const string[], & index)
121
+ {
122
+ new length = strlen (string);
123
+ while ((index < length) && (string[index] <= ' ' ))
124
+ {
125
+ index++ ;
126
+ }
127
+
128
+ new offset = index;
129
+ new result[20 ];
130
+ while ((index < length) && (string[index] > ' ' ) && ((index - offset) < (sizeof (result) - 1 )))
131
+ {
132
+ result[index - offset] = string[index];
133
+ index++ ;
134
+ }
135
+ result[index - offset] = EOS;
136
+ return result;
137
+ }
0 commit comments