GTAOnline.net

San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: Winklevows le 11 Décembre 2010, 18:37:34

Titre: Aide pour creer un timer
Posté par: Winklevows le 11 Décembre 2010, 18:37:34
Bonjour,
J'ai réussi a créer un timer en m'inspirant des timers déjà présent dans mon GM, visiblement il fonctionne mais je ne suis absolument pas sur de ce que j'ai fais, pouvez vous jeter un coup d'œil pour voir si j'ai fais des erreurs ?

Alors je vous explique l'utilité tu timer :
Un policier Y menotte un suspect X. Le suspect X va être dé-menotté dans 30secs pour évité qu'il reste incontrôlable :

forward AntiCuffAbuse();...
public AntiCuffAbuse()
{
    for (new i = 0; i < MAX_PLAYERS; i++)
  {
if(cuffed[i] == 1 && IsPlayerConnected(i))
{
           
cuffed[i] =0;
        TogglePlayerControllable(i, 1);
        StopLoopingAnim(i);
        new pname[30];
        new string[100];
        GetPlayerName(i, pname, 24);
        format(string, sizeof(string), "Les menottes de %s(%d) ont été retirées par notre système Anti-Abuse.",pname,i);
        SendClientMessageToAll(COLOR_DODGERBLUE, string);
        }
}
}
...
Si la commande /cuff est utilisé :
    if(GetPlayerState(giveplayerid) == PLAYER_STATE_ONFOOT) {
    SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Menotté_|");
    format(string, sizeof(string), "%s(%d) vous a mis des menottes aux poignets. Utilisez /breakcuffs pour tenter une évasion",oname, playerid);
    SendClientMessage(giveplayerid, COLOR_DODGERBLUE, string);
    TogglePlayerControllable(giveplayerid, 0);
    cuffed[giveplayerid] =1;
    LoopingAnim(giveplayerid, "ped", "cower", 3.0, 1, 0, 0, 0, 0); // Taking Cover
    SetTimer("AntiCuffAbuse", 30000,0);
    SendClientMessage(playerid, 0xA9A9A9AA, "|_Suspect Menotté_|");
format(string, sizeof(string), "Vous avez mis des menottes à %s(%d). Utilisez /search (id) pour rechercher des objets illégaux", pname, giveplayerid);
    SendClientMessage(playerid, COLOR_DODGERBLUE, string);
    format(string, sizeof(string), "NE PARTEZ PAS EN LAISSANT UN SUSPECT MENOTTÉ. VOUS SEREZ KICKÉ SI VOUS LE FAITES.", pname, giveplayerid);
    SendClientMessage(playerid, COLOR_DODGERBLUE, string);
    }

J'ai testé plusieurs fois et visiblement tout fonctionne mais une fois le joueur n'est resté menotté que 3 ou 4 secondes.
Titre: Re : Aide pour creer un timer
Posté par: Pixect le 11 Décembre 2010, 23:00:23
Salut,

Ça m'a l'air bon, mais utilise plutôt SetTimerEx que SetTimer.

++
Lloyd
Titre: Re : Aide pour creer un timer
Posté par: bibidu60 le 08 Septembre 2011, 22:43:28
Bonjour,
J'ai un petit problème, je ne c'est pas ou placer ce code, pourriez vous me l'indiquer ?
(http://www.gtaonline.fr/forums/Themes/proton/images/warnwarn.gif) Up d'un an !
Titre: Re : Aide pour creer un timer
Posté par: nivi le 09 Septembre 2011, 01:52:23
public OnGameModeInit :cheers