Raised This Month: $ Target: $400
 0% 

print in another lang


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
newone123
Junior Member
Join Date: May 2021
Old 05-17-2021 , 14:22   Re: print in another lang
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Attach the plugin and JSON file so that we can see and test the code.
I think its really unrelated because eng it reads excellent hebrew not.
after i get json file and read it
Code:
public read() {
	new JSON:decodingJson = json_parse("/addons/java/alerts.json", true)
	if(json_is_array(decodingJson)) {
		new JSON:firstObj = json_array_get_value(decodingJson, 0)
		if(firstObj) {
			new cityKey[] = "data", dateKey[] = "alertDate"
			new vcity[101], vdate[101]
			new ok = 0
			if(json_object_get_string(firstObj, cityKey, vcity, charsmax(vcity))) ok++
			else client_print(0, print_chat, "[AMX] cant get the city by key = %s", vcity)
			if(json_object_get_string(firstObj, dateKey, vdate, charsmax(vdate))) ok++
			else client_print(0, print_chat, "[AMX] cant get the date by key = %s", vdate)
			if(ok == 2) {
				new ocity [101], odate[101] 
				get_pcvar_string(cvar_City, ocity, charsmax(ocity))
				get_pcvar_string(cvar_Date, odate, charsmax(odate))
				if(!equal(ocity, vcity) || !equal(odate, vdate)) {
					client_print(0, print_chat, "[AMX] alert %s under attack!", vcity)
					set_pcvar_string(cvar_City, vcity)
					set_pcvar_string(cvar_Date, vdate)
					client_cmd(0, "spk %s", "/addons/java/alert.wav")
				} else client_print(0, print_chat, "[AMX] the last attack was in  %s ", vcity)
			}
			json_free(firstObj)
		} else client_print(0, print_chat, "[AMX] cant load first object")
		json_free(decodingJson)
	} else client_print(0, print_chat, "[AMX] json file not readable")
}
the json file that i received from curl (just few lines):
Code:
[{"alertDate":"2021-05-16 18:49:19","title":"התרעות פיקוד העורף","data":"אורים"},{"alertDate":"2021-05-16 18:49:17","title":"התרעות פיקוד העורף","data":"מגן"},{"alertDate":"2021-05-16 18:49:17","title":"התרעות פיקוד העורף","data":"ניר עוז"},{"alertDate":"2021-05-16 18:49:17","title":"התרעות פיקוד העורף","data":"עין הבשור"},{"alertDate":"2021-05-16 18:42:40","title":"התרעות פיקוד העורף","data":"ארז"},{"alertDate":"2021-05-16 18:27:55","title":"התרעות פיקוד העורף","data":"כיסופים"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"אזור תעשייה עד הלום"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"אמונים"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"בית עזרא"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"גבעתי"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"ניצן"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"עזר"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"עזריקם"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"שדה עוזיהו"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"אשדוד - א,ב,ד,ה"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"אשדוד - ג,ו,ז"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"אשדוד - ח,ט,י,יג,יד,טז"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"שתולים"},{"alertDate":"2021-05-16 18:17:24","title":"התרעות פיקוד העורף","data":"אשדוד - יא,יב,טו,יז,מרינה"},{"alertDate":"2021-05-16 18:17:18","title":"התרעות פיקוד העורף","data":"בת הדר"},{"alertDate":"2021-05-16 18:17:18","title":"התרעות פיקוד
newone123 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode