GTAOnline.net
San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: Komolos le 04 Octobre 2010, 09:43:34
-
Bonjour,
Depuis avant hier j'ai commencé à scripté un système /mourrir mais sans réussite :'(
Si vous savez pourquoi ça ne freeze pas le joueurs et ça ne marche carrément pas ig merci de m'expliquer ou corrigé le code ci dessous
public Mourir()
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gPlayerSpawned[i] == 1)
{
new Float:health;
GetPlayerHealth(i, health);
if(health <= 10)
{
if(IsPlayerInAnyVehicle(i))
{
RemovePlayerFromVehicle(i);
ApplyAnimation(i, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
TogglePlayerControllable(i, 0);
GameTextForPlayer(i, "~r~Vous etes blesse, faites /mourrir ou /service medecin ", 5000, 3);
SendClientMessage(i, COLOR_WHITE, "Vous êtes blessé, faites /mourrir ou /appeler 103");
}
else
{
ApplyAnimation(i, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
TogglePlayerControllable(i, 0);
GameTextForPlayer(i, "~r~Vous etes blesse, faites /mourrir ou /service medecin !", 5000, 3);
SendClientMessage(i, COLOR_WHITE, "Vous êtes blessé, faites /mourrir ou /service medecin !");
}
}
}
}
}
return 1;
}
-
Mais peut-être parce que mourir prend qu'un seul R :)
-
Pourquoi une animation? Tu peux faire une bete commande /kill comme ici:
if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid, 0);
SendClientMessage(playerid, COLOR_YELLOW, "Vous vous êtes suicidé.");
return 1;
}
:dejadehors
-
Tu m'as pas fortement compris Karting, j'ai déjà mon /mourrir, mais mon public bugs, j'aimerai le réparé pour qu'il marche
-
Ta mis un Timer pour qu'il cherche quand le joueur lui reste peu de vie ?
-
Non, j'en n'ai pas mis un, je bloque à ça enfête..
-
Cherche dans ton gm:
public OtherTimer()
{
....
}
C'est un timer qui cherche toute les seconde et intègre ton code dedans.
Sinon pour créer un timer:
Tu ajoute en haut de ton script:
new testimer;
Puis ta callback:
public mourir()
{
ton code....
}
Oublie pas de déclarer ta callback.
Ensuite tu cherche:
OnGameModeInit()
Tu cherche tes timer tout en bas de la callback
Et tu ajoute :
testimer = SetTimer("mourir", 500, 1); // 500 est le temps qui va appeller la callback donc ici c'est toute les 0.5 secondes
J'espère t'avoir aidé ;)