Battery Percent System - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Battery Percent System (
/showthread.php?tid=653734)
Battery Percent System -
Hiei - 11.05.2018
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
Re: Battery Percent System -
Vennox - 11.05.2018
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;
}
Re: Battery Percent System -
Hiei - 12.05.2018
Quote:
Originally Posted by Vennox
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;
}
|
Thanks you man

it worked