Battery Percent System
#1

Hi there, i'm newbie, i have one script about phone, i want roleplay, but if roleplay, i want my phone have battery percent, i want every one minute, it lost 1% battery percent, and if battery = 0%, phone will shutdown, how to do that script ? Help me please.
p/s sorry about my english
Reply
#2

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

Reply
#3

Quote:
Originally Posted by Vennox
Посмотреть сообщение
PHP код:
#include <a_samp>
new batteryprecent[MAX_PLAYERS];
forward OneMinuteTimer();
public 
OneMinuteTimer(){
    for(new 
iMAX_PLAYERSi++){
        if(
batteryprecent[i] != 0){
            
batteryprecent[i] -= 1;
            new 
string[64];
            
format(string64"Your battery precent dropped to %d precent"batteryprecent[i]);
            
SendClientMessage(i0xFFFF00FFstring);
            if(
batteryprecent[i] == 0){
                
SendClientMessage(i0xFF0000FF"You phone battery is dead.");
                
//your code that shuts down the phone here.
            
}
        }
    }
}
public 
OnPlayerConnect(playerid){
    
batteryprecent[playerid] = 100;
    
SendClientMessage(playerid0x00FF00FF"While you were offline, your phone battery charged to 100 precent.");
    return 
1;
}
public 
OnGameModeInit(){
    
SetTimer("OneMinuteTimer"600001); //60000 miliseconds = 60 seconds = 1 minute
    
return 1;

Thanks you man it worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)