11.05.2018, 15:19
PHP код:
#include <a_samp>
new batteryprecent[MAX_PLAYERS];
forward OneMinuteTimer();
public OneMinuteTimer(){
for(new i; i < MAX_PLAYERS; i++){
if(batteryprecent[i] != 0){
batteryprecent[i] -= 1;
new string[64];
format(string, 64, "Your battery precent dropped to %d precent", batteryprecent[i]);
SendClientMessage(i, 0xFFFF00FF, string);
if(batteryprecent[i] == 0){
SendClientMessage(i, 0xFF0000FF, "You phone battery is dead.");
//your code that shuts down the phone here.
}
}
}
}
public OnPlayerConnect(playerid){
batteryprecent[playerid] = 100;
SendClientMessage(playerid, 0x00FF00FF, "While you were offline, your phone battery charged to 100 precent.");
return 1;
}
public OnGameModeInit(){
SetTimer("OneMinuteTimer", 60000, 1); //60000 miliseconds = 60 seconds = 1 minute
return 1;
}