· 7 years ago · Jan 18, 2019, 02:50 PM
1//============
2// SCRIPT CRIADO POR: FROST
3//============
4//============
5/* TABELAS SQL:
6
7CREATE TABLE IF NOT EXISTS `sistema_de_plantas` (
8 `char_id` INT(11) NOT NULL,
9 `name` VARCHAR(30) NOT NULL,
10 `mapa` VARCHAR(12) NOT NULL,
11 `posi_x` INT(3) NOT NULL,
12 `posi_y` INT(3) NOT NULL,
13 `plant_id` INT(3) NOT NULL,
14 `plant_stage` INT(1) NOT NULL,
15 `plant_time` INT(11) NOT NULL,
16 KEY `char_id` (`char_id`)
17) ENGINE=MyISAM;
18*/
19
20function script plant_system {
21
22 getmapxy(.@map$, .@mapx, .@mapy, UNITTYPE_PC);
23 .@mapy--;
24
25 query_sql "SELECT `plant_id` FROM `sistema_de_plantas` WHERE `mapa`='"+.@map$+"' AND `posi_x`="+.@mapx+" AND `posi_y`="+.@mapy+"",.@pidW;
26
27 if(.@pidW)
28 {
29 mes "Já existe uma planta aqui!";
30 getitem 7193,1;
31 close;
32 }
33
34 mes "Você quer Plantar aqui? ";
35 if(select("Sim:Não")==2){ getitem 7193,1; close; }
36
37 close2;
38 .@cid = getcharid(0);
39 .@nid$ = strcharinfo(0);
40 query_sql "SELECT COUNT(`char_id`) FROM `sistema_de_plantas` WHERE `char_id`='"+.@cid+"'",.@rst;
41
42 for(set .@i,0; .@i<=.@rst; set .@i,.@i+1)
43 {
44 query_sql "SELECT `plant_id` FROM `sistema_de_plantas` WHERE `char_id`="+getcharid(0)+" ORDER BY `plant_id` ASC",.@rrst;
45 if(.@rrst[.@i] != .@i && .@chk < 1){ set .@rst,.@i; set .@chk,1; }
46 }
47
48 showscript "Plantando...";
49 progressbar "0xFFFFFF", 1;
50 set .@pName$," #"+.@rst+getcharid(0)+"";
51 duplicatenpc("planta2", .@pName$, sprintf($cid$), .@map$, .@mapx, .@mapy, DIR_SOUTH, 557);
52
53 set .@pTime,gettimetick(2)+60; //60 segundos para regar pela 1º vez
54
55 query_sql "INSERT INTO `sistema_de_plantas` (`char_id`,`name`,`mapa`,`posi_x`,`posi_y`,`plant_id`,`plant_stage`,`plant_time`) VALUES ("+.@cid+",'"+.@nid$+"','"+.@map$+"',"+.@mapx+","+.@mapy+","+.@rst+",0,"+.@pTime+")";
56 end;
57}
58
59- script planta2 -1,{
60
61 query_sql "SELECT `posi_x` FROM `sistema_de_plantas` WHERE `char_id` = "+getcharid(0)+" AND `mapa`='"+strcharinfo(3)+"'",.@px2;
62
63 if(.@px2)
64 {
65 getmapxy(.@map$, .@x, .@y, UNITTYPE_NPC);
66 query_sql "SELECT `plant_id`,`posi_x`,`plant_stage`,`plant_time` FROM `sistema_de_plantas` WHERE `char_id` = "+getcharid(0)+" AND `mapa`='"+.@map$+"' AND `posi_x`="+.@x+" AND `posi_y`="+.@y+"",.@pidC,.@px,.@stage,.@time;
67
68 if(.@px)
69 {
70
71 mes "[^20B2AA Planta ^000000]";
72 mes "ID Planta : "+.@pidC;
73 mes "Nome Planta: "+strnpcinfo(0)+"";
74 mes "Mapa: "+.@map$;
75 mes "Posição X: "+.@x;
76 mes "Posição Y: "+.@y;
77 mes "Estágio: "+.@stage;
78
79 set .@calcT,.@time-gettimetick(2);
80 mes ""+(.@stage == 3 ? "Estágio Final:":"Próximo Estágio:")+" "+(.@calcT < 60 ? (.@calcT < 0 ? "0":.@calcT+"seg"):(.@calcT/60)+"min");
81
82 menu (.@stage < 3 ? "Regar":"")+"",-,(.@stage > 0 ? "Cortar":"")+"",-,"ChatRoom",-,"Sair",-;
83 set .@mn,@menu;
84
85 switch(.@mn)
86 {
87 case 1:
88 if(gettimetick(2) < .@time){ next; mes "Você ainda não pode regar!"; close; }
89
90 switch(.@stage)
91 {
92 case 0: //30min
93
94 if(countitem(523) < 1){ next; mes "Para regar a planta você precisa de 1x "+getitemname(523)+" !"; close; }
95 set .@pTime,gettimetick(2)+1800;
96 query_sql "UPDATE `sistema_de_plantas` SET `plant_stage`=1,`plant_time`="+.@pTime+" WHERE `char_id` = "+getcharid(0)+" AND `mapa`='"+.@map$+"' AND `posi_x`="+.@x+" AND `posi_y`="+.@y+"";
97 classchange(976,1);
98 delitem 523,1;
99 break;
100
101 case 1: //30min
102
103 if(countitem(523) < 1){ next; mes "Para regar a planta você precisa de 1x "+getitemname(523)+" !"; close; }
104 set .@pTime,gettimetick(2)+1800;
105 query_sql "UPDATE `sistema_de_plantas` SET `plant_stage`=2,`plant_time`="+.@pTime+" WHERE `char_id` = "+getcharid(0)+" AND `mapa`='"+.@map$+"' AND `posi_x`="+.@x+" AND `posi_y`="+.@y+"";
106 classchange(527,1);
107 delitem 523,1;
108 break;
109
110 case 2: //1h30min
111
112 if(countitem(523) < 1){ next; mes "Para regar a planta você precisa de 1x "+getitemname(523)+" !"; close; }
113 set .@pTime,gettimetick(2)+5400;
114 query_sql "UPDATE `sistema_de_plantas` SET `plant_stage`=3,`plant_time`="+.@pTime+" WHERE `char_id` = "+getcharid(0)+" AND `mapa`='"+.@map$+"' AND `posi_x`="+.@x+" AND `posi_y`="+.@y+"";
115 classchange(613,1);
116 delitem 523,1;
117 break;
118
119 default:
120 mes "ERRO: 1"; close;
121 }
122
123 close;
124
125 case 2:
126 close2;
127 set .@sqlD,query_sql("DELETE FROM `sistema_de_plantas` WHERE `char_id` = "+getcharid(0)+" AND `mapa`='"+.@map$+"' AND `posi_x`="+.@x+" AND `posi_y`="+.@y+" AND `plant_id`="+.@pidC+"");
128 if(.@sqlD) dispbottom "Erro inesperado ao remover a planta do db!";
129 if(getwaitingroomstate(3,strnpcinfo(0))) delwaitingroom strnpcinfo(0);
130 duplicateremove(strnpcinfo(0));
131 end;
132 case 3:
133 if(select("Ativar Chat:Desativar Chat")==2){ delwaitingroom strnpcinfo(0); close;}
134 if(!getwaitingroomstate(3,strnpcinfo(0))){ mes "já está ativo!"; close; }
135 waitingroom "[ "+strcharinfo(0)+" ]",0;
136 close;
137
138 default:
139 close;
140 }
141 }
142 }
143
144 dispbottom "[^20B2AA Planta ^000000]";
145 dispbottom "Essa Planta não é sua.";
146 end;
147}
148
149- script markMapView -1,{
150
151
152OnPCLoginEvent:
153
154 query_sql "SELECT `plant_id` FROM `sistema_de_plantas` WHERE `char_id`="+getcharid(0)+" AND `mapa`='"+strcharinfo(3)+"'",.@pidL;
155 if(getarraysize(.@pidL))
156 {
157 for(set .@i,0;.@i<getarraysize(.@pidL); set .@i,.@i+1)
158 {
159 query_sql "SELECT `posi_x`,`posi_y` FROM `sistema_de_plantas` WHERE `char_id`="+getcharid(0)+" AND `plant_id`="+.@pidL[.@i]+"",.@mapx,.@mapy;
160 viewpoint 0,.@mapx,.@mapy,(.@i+1),0xFF0000;
161 }
162 }
163end;
164}