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

Titre: Aide /mourrir
Posté 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;
}
Titre: Re : Aide /mourrir
Posté par: Aegoss le 04 Octobre 2010, 09:59:22
Mais peut-être parce que mourir prend qu'un seul R :)
Titre: Re : Aide /mourrir
Posté par: Karting06 le 04 Octobre 2010, 10:47:23
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
Titre: Re : Aide /mourrir
Posté par: Komolos le 04 Octobre 2010, 12:10:12
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
Titre: Re : Aide /mourrir
Posté par: Katou76 le 04 Octobre 2010, 23:57:43
Ta mis un Timer pour qu'il cherche quand le joueur lui reste peu de vie ?
Titre: Re : Aide /mourrir
Posté par: Komolos le 05 Octobre 2010, 08:41:06
Non, j'en n'ai pas mis un, je bloque à ça enfête..
Titre: Re : Aide /mourrir
Posté par: Katou76 le 05 Octobre 2010, 13:19:07
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é ;)