Sziasztok. Rengeteg helyen láttam hogy a god scripteket vagy timerrel vagy 99999999999999hp-val csinálják, ezért csináltam egy másik megoldást ami talán egyszerűbb, de hatásosabb lesz.
Készítő:MichaelTMorales
Sorok:28
Készítési idő:1-2 perc
#include <a_samp>
new God[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, \"/god\", true))
{
if(God[playerid] == 0) {
God[playerid] = 1;
SendClientMessage(playerid, -1, \"God mód bekapcsolva\");
return 1;
}
if(God[playerid] == 1) {
God[playerid] = 0;
SendClientMessage(playerid, -1, \"God mód kikapcsolva!\");
return 1;
}
return 1;
}
return 0;
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(God[playerid] == 1) return SetPlayerHealth(playerid, 100);
return 1;
}
Timerrel takarékosabb szerintem.
Vagy még annyit írj bele, hogy akkor állítsa át a játékos életét 100-ra, ha az nem egyenlő 100.-al.
+ itt van egy kicsit rövidebben a /god parancs ZCMD-vel:
CMD:god(playerid) {
God[playerid] = !God[playerid];
SendClientMessage(playerid, -1, !God[playerid]?(\"God mód kikapcsolva!\"):(\"God mód bekapcsolva!\"));
return 1;
}
Segítek:
#define INFINITY (Float:0x7F800000)
stock GodMode(playerid)
{
return SetPlayerHealth(playerid,INFINITY);
}
A scripted eleve rossz, mert ha olyan damage-t kapsz, amely 100-nál nagyobb, akkor hiába adod neki vissza az életét, meg fog halni.
Mégegy megoldás:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(God[playerid] == 1)
return 0;
else
return 1;
}
Ez hasonlít ahhoz, amit az eredeti script írója akart elérni.
Segítek:
#define INFINITY (Float:0x7F800000)
stock GodMode(playerid)
{
return SetPlayerHealth(playerid,INFINITY);
}
A scripted eleve rossz, mert ha olyan damage-t kapsz, amely 100-nál nagyobb, akkor hiába adod neki vissza az életét, meg fog halni.
Perfekt. Honnan van az érték? :D
OnPlayerTakeDamage-et használj szerintem, és az élet több legyen mint 100, pl. 1000 vagy 10000 ;)
Felesleges
#define INFINITY (Float:0x7F800000)
stock GodMode(playerid)
{
return SetPlayerHealth(playerid,INFINITY);
}
[/quote]
Ezzel le van minden tudva. :D