Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <YSI_Coding\y_hooks>
- //ตัวแปร
- new Text3D:mailk[9];
- new ReTimerMailk[9];
- new Playermilk[MAX_PLAYERS];
- //โหลดบนเซิฟเวอร์
- hook OnGameModeInit(){
- new string[256];
- //น้องวัว
- CreateObject(19833, -1098.430053, -1616.589965, 75.337196, 0.000000, 0.000000, 0.000000);//1
- CreateObject(19833, -1101.109985, -1616.540039, 75.397201, 0.000000, 0.000000, 0.000000);//2
- CreateObject(19833, -1104.205932, -1616.501586, 75.337181, 0.000000, 0.000000, 4.299998);//3
- CreateObject(19833, -1107.583129, -1616.422485, 75.297172, 0.000000, 0.000000, 0.000000);//4
- CreateObject(19833, -1110.278076, -1616.505615, 75.327186, 0.000000, 0.000000, 0.000000);//5
- CreateObject(19833, -1113.173461, -1616.535400, 75.347183, 0.000000, 0.000000, 0.000000);//6
- CreateObject(19833, -1116.582519, -1616.511230, 75.593940, 0.000000, 0.000000, 0.000000);//7
- CreateObject(19833, -1119.169799, -1619.094238, 75.493965, 0.000000, 0.000000, 88.299995);//8
- CreateObject(19833, -1119.327758, -1622.554443, 75.333938, 0.000000, 0.000000, 85.900009);//9
- //กรองนมวัว
- CreateObject(958, -1112.387939, -1678.713378, 76.237182, 0.000000, 0.000000, 0.000000);
- Create3DTextLabel("กด N \n เพื่อ กรองนมวัวใส่ขวด", 0xFFA500AA, -1112.387939, -1678.713378, 76.237182, 10.0, 0, 0);//1
- SetTimer("UpdateTimer_Mailk", 1000, 1);
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[0]);
- mailk[0] = Create3DTextLabel(string, 0xFFA500AA, -1098.430053, -1616.589965, 75.337196+1, 10.0, 0, 0);//1
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[1]);
- mailk[1] = Create3DTextLabel(string, 0xFFA500AA, -1101.109985, -1616.540039, 75.397201+1, 10.0, 0, 0);//2
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[2]);
- mailk[2] = Create3DTextLabel(string, 0xFFA500AA, -1104.205932, -1616.501586, 75.337181+1, 10.0, 0, 0);//3
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[3]);
- mailk[3] = Create3DTextLabel(string, 0xFFA500AA, -1107.583129, -1616.422485, 75.297172+1, 10.0, 0, 0);//4
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[4]);
- mailk[4] = Create3DTextLabel(string, 0xFFA500AA, -1110.278076, -1616.505615, 75.327186+1, 10.0, 0, 0);//5
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[5]);
- mailk[5] = Create3DTextLabel(string, 0xFFA500AA, -1113.173461, -1616.535400, 75.347183+1, 10.0, 0, 0);//6
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[6]);
- mailk[6] = Create3DTextLabel(string, 0xFFA500AA, -1116.582519, -1616.511230, 75.593940+1, 10.0, 0, 0);//7
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[7]);
- mailk[7] = Create3DTextLabel(string, 0xFFA500AA, -1119.169799, -1619.094238, 75.493965+1, 10.0, 0, 0);//8
- format(string, 256, "กด N เพื่อรีดน้ำวัว",ReTimerMailk[8]);
- mailk[8] = Create3DTextLabel(string, 0xFFA500AA, -1119.327758, -1622.554443, 75.333938+1, 10.0, 0, 0);//9
- return 1;
- }
- //คำสั่ง
- hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
- if(newkeys & KEY_NO){
- if(PlayerToPoint(2.0, playerid, -1098.430053, -1616.589965, 75.337196)){//1
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[0] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[0] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- return 1;
- }
- else if(PlayerToPoint(2.0, playerid, -1101.109985, -1616.540039, 75.397201)){//2
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[1] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[1] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1104.205932, -1616.501586, 75.337181)){//3
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[2] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[2] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1107.583129, -1616.422485, 75.297172)){//4
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[3] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[3] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1110.278076, -1616.505615, 75.327186)){//5
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[4] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[4] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1113.173461, -1616.535400, 75.347183)){//6
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[5] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[5] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1116.582519, -1616.511230, 75.593940)){//7
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[6] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[6] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1119.169799, -1619.094238, 75.493965)){//8
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[7] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[7] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1119.327758, -1622.554443, 75.333938)){//8
- if(Playermilk[playerid] >= 10) return SendClientMessage(playerid, YELLOW, "[!]: คุณเก็บนมวัวมากกว่า 10 ลิตรไม่ได้");
- if(ReTimerMailk[8] > 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}ยังไม่ถึงเวลารีด...");
- ReTimerMailk[8] = 60;
- defer MilkTaking(playerid);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}คุณกำลังรีดนมวัว...");
- TogglePlayerControllable(playerid, 0);
- }
- else if(PlayerToPoint(2.0, playerid, -1112.387939, -1678.713378, 76.237182)){
- if(Playermilk[playerid] > 0){
- if(Playermilk[playerid] <= 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414} คุณไม่มีน้ำนม สักลิตร..");
- defer milkcraft(playerid);
- TogglePlayerControllable(playerid, 0);
- SendClientMessage(playerid, YELLOW, "[+]: {6EF83C}กำลังกรองนมใส่ ขวด...");
- }
- }
- else if(PlayerToPoint(2.0, playerid, 1023.6880,-1912.9935,12.7504)){
- new string[256];
- format(string, 256, "คุณมี ขวดนมวัว จำนวน %d \nต้องการขาย\nระบุจำนวน", Player[playerid][pmailk]);
- Dialog_Show(playerid,sell_milk, DIALOG_STYLE_INPUT,"ขายนมวัว",string, "ตกลง", "ยกเลิก");
- }
- }
- return 1;
- }
- Dialog:sell_milk(playerid, response, listitem, inputtext[]) {
- new query[256];
- new amomt = strval(inputtext);
- if(!response) return 1;
- if(amomt <= 0) return SendClientMessage(playerid, YELLOW, "[!]: {F81414}จำนวน 0 ไม่สมารถใช้ได้");
- new sell = 13 * amomt;
- SafeGivePlayerMoney(playerid, sell);
- Player[playerid][pmailk] -= amomt;
- SendClientMessageEx(playerid, YELLOW, "[+]: {6EF83C} คุณได้ขาย ขวดนมวัว จำนวน %d ขวด",amomt);
- SendClientMessageEx(playerid, YELLOW, "[+]: {6EF83C} คุณได้รับเงิน จากการขาย ขวดนมวัว จำนวน %d บาท",sell);
- mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `pmailk` = %d WHERE `id` = %d LIMIT 1", Player[playerid][pmailk],Player[playerid][ID]);
- mysql_tquery(g_SQL, query);
- return 1;
- }
- timer milkcraft[5000](playerid){
- new item = 1 + random(2);
- new query[256];
- TogglePlayerControllable(playerid, 1);
- Playermilk[playerid] -= 2;
- Player[playerid][pmailk] += item;
- SendClientMessageEx(playerid, YELLOW, "[+]: {6EF83C}คุณได้รับ ขวดนมวัว จำนวน %d ขวด", item);
- mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `pmailk` = %d WHERE `id` = %d LIMIT 1", Player[playerid][pmailk],Player[playerid][ID]);
- mysql_tquery(g_SQL, query);
- return 1;
- }
- timer MilkTaking[5000](playerid){
- new item = 1 + random(2);
- TogglePlayerControllable(playerid, 1);
- Playermilk[playerid] += item;
- SendClientMessageEx(playerid, YELLOW, "[+]: {6EF83C}คุณได้รับนมวัว จำนวน %d ลิตร", item);
- return 1;
- }
- //อัดเดท
- forward UpdateTimer_Mailk();
- public UpdateTimer_Mailk(){
- new string[256];
- if(ReTimerMailk[0] > 0){
- ReTimerMailk[0] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[0]);
- Update3DTextLabelText(mailk[0], 0xFFA500AA, string);
- if(ReTimerMailk[0] <= 0){Update3DTextLabelText(mailk[0], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[0] = 0;}
- }
- if(ReTimerMailk[1] > 0){
- ReTimerMailk[1] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[1]);
- Update3DTextLabelText(mailk[1], 0xFFA500AA, string);
- if(ReTimerMailk[1] <= 0){Update3DTextLabelText(mailk[1], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[1] = 0;}
- }
- if(ReTimerMailk[2] > 0){
- ReTimerMailk[2] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[2]);
- Update3DTextLabelText(mailk[2], 0xFFA500AA, string);
- if(ReTimerMailk[2] <= 0){Update3DTextLabelText(mailk[2], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[2] = 0;}
- }
- if(ReTimerMailk[3] > 0){
- ReTimerMailk[3] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[3]);
- Update3DTextLabelText(mailk[3], 0xFFA500AA, string);
- if(ReTimerMailk[3] <= 0){Update3DTextLabelText(mailk[3], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[3] = 0;}
- }
- if(ReTimerMailk[4] > 0){
- ReTimerMailk[4] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[4]);
- Update3DTextLabelText(mailk[4], 0xFFA500AA, string);
- if(ReTimerMailk[4] <= 0){Update3DTextLabelText(mailk[4], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[4] = 0;}
- }
- if(ReTimerMailk[5] > 0){
- ReTimerMailk[5] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[5]);
- Update3DTextLabelText(mailk[5], 0xFFA500AA, string);
- if(ReTimerMailk[5] <= 0){Update3DTextLabelText(mailk[5], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[5] = 0;}
- }
- if(ReTimerMailk[6] > 0){
- ReTimerMailk[6] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[6]);
- Update3DTextLabelText(mailk[6], 0xFFA500AA, string);
- if(ReTimerMailk[6] <= 0){Update3DTextLabelText(mailk[6], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[6] = 0;}
- }
- if(ReTimerMailk[7] > 0){
- ReTimerMailk[7] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[7]);
- Update3DTextLabelText(mailk[7], 0xFFA500AA, string);
- if(ReTimerMailk[7] <= 0){Update3DTextLabelText(mailk[7], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[7] = 0;}
- }
- if(ReTimerMailk[8] > 0){
- ReTimerMailk[8] --;
- format(string, sizeof(string), "จะสมารถรีดได้อีก \n%d",ReTimerMailk[8]);
- Update3DTextLabelText(mailk[8], 0xFFA500AA, string);
- if(ReTimerMailk[8] <= 0){Update3DTextLabelText(mailk[8], 0xFFA500AA, "กด N เพื่อรีดน้ำวัว");ReTimerMailk[8] = 0;}
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement