Quantcast
Channel: Forum VeryGames
Viewing all articles
Browse latest Browse all 5196

Plugin /jail

$
0
0
Bonjour Misterpown et moi codons ce plugin, mais lors de la compilation nous obtenons plusieurs erreurs : http://img849.imageshack.us/img849/2...nstitre2li.jpg Sa serait sympas de nous éclairé a ce sujet merci.

Explication du plugin : Plugin permettant de téléporter un joueur à des coordonnées précise en le visant. Dés que que le joueur est téléporté un menu s'ouvre pour celui qui a jail le joueur, ce menu permet de choisir la peine admise au joueur cela déterminera le temps que va rester le joueur en prison. Une fois le temps terminé le joueur est téléporté à d'autres coordonnées parmis les 3 coordonnées définits.


- J'aimerais si possible corriger toutes les erreurs lors de la compilation. (http://img849.imageshack.us/img849/2...nstitre2li.jpg).
- J'aimerais aussi si c'est possible afficher sur l’écran du prisonnier le temps qui lui reste en prison en PrinttochatCenter.
- Dernière petit chose, si c'est possible de bloquer le tchat au prisonnier le temps de sa jail, qu'il ne puisse pas utiliser de commande.


Voici le code :


Code:

#include <sdktools>#include <cstrike>
#include <sdkhooks>
#include <sourcemod>


#pragma semicolon 1
#define LOGO    "[RP]"


new bool:g_booljail[MAXPLAYERS+1] = false;
new Handle:g_jailtimer[MAXPLAYERS+1] = { INVALID_HANDLE, ... };
new Handle:g_jailreturn[MAXPLAYERS+1] = { INVALID_HANDLE, ... };
new g_jailtime[MAXPLAYERS+1] = 0;
new g_IsInJail[MAXPLAYERS+1] = 0;


public OnPluginStart()
{
    RegConsoleCmd("sm_jail", Command_Jail);
    RegConsoleCmd("sm_jaillist", Command_Jaillist);
}




public Action:Command_Jail(client, args)
{
    if (IsClientInGame(client))
    {
        if (IsPlayerAlive(client))
        {
            if (GetClientTeam(client) == 3)
            {
                h[client] = GetClientAimTarget(client, true);
               
                if(h[client] != -1)
                {
                    if (g_invisible[client] == 0)
                    {
                        TransactionWith[client] = h[client];
                        TransactionWith[h[client]] = client;
                       
                        if (h[client] < 1 || h[client] > MaxClients)
                        {
                            PrintToChat(client, "%s Vous devez viser un joueur.", LOGO);
                            return Plugin_Handled;
                        }
                       
                        new Float:entorigin[3], Float:clientent[3];
                        GetEntPropVector(h[client], Prop_Send, "m_vecOrigin", entorigin);
                        GetEntPropVector(client, Prop_Send, "m_vecOrigin", clientent);
                        new Float:distance = GetVectorDistance(entorigin, clientent);
                       
                        if (GetClientTeam(h[client]) == 2)
                        {
                            if (distance <= 1000)
                            {
                                switch (GetRandomInt(1, 6))
                                {
                                    case 1:
                                    {
                                        TeleportEntity(h[client], Float:{ -2226.0, 4895.0, -250.0 }, NULL_VECTOR, NULL_VECTOR);
                                    }
                                           
                                    case 2:
                                    {
                                        TeleportEntity(h[client], Float:{ -2228.0, 4984.0, -250.0 }, NULL_VECTOR, NULL_VECTOR);
                                    }
                                       
                                    case 3:
                                    {
                                        TeleportEntity(h[client], Float:{ -2230.0, 5071.0, -250.0 }, NULL_VECTOR, NULL_VECTOR);
                                    }
                                       
                                    case 4:
                                    {
                                        TeleportEntity(h[client], Float:{ -2416.0, 5056.0, -250.0 }, NULL_VECTOR, NULL_VECTOR);
                                    }
                                    case 5:
                                    {
                                        TeleportEntity(h[client], Float:{ -2416.0, 4966.0, -250.0}, NULL_VECTOR, NULL_VECTOR);
                                    }
                                    case 6:
                                    {
                                        TeleportEntity(h[client], Float:{ -2414.0, 4880.0, -250.0 }, NULL_VECTOR, NULL_VECTOR);
                                    }
                                }
                               
                                PrintToChat(client, "%s Tu as emprisonné le joueur : %N", LOGO, h[client]);
                                PrintToChat(h[client], "%s Tu as été emprisonné par : %N", LOGO, client);
                               
                                disarm(h[client]);
                                GivePlayerItem(h[client], "weapon_knife");
                                SetClientListeningFlags(h[client], VOICE_MUTED);
                               
                                gObj[h[client]] = -1;
                                grab[h[client]] = false;
                                StopSound(h[client], SNDCHAN_AUTO, gSound);
                               
                                g_IsInJail[h[client]] = 1;
                               
                                new Handle:menu = CreateMenu(Menu_Jail);
                                SetMenuTitle(menu, "Choisis la peine pour %N :", h[client]);
                                AddMenuItem(menu, "meurtrep", "Meurtre sur policier.");
                                AddMenuItem(menu, "meurtrec", "Meurtre sur civil.");
                                AddMenuItem(menu, "tentative", "Tentative de meurtre.");
                                AddMenuItem(menu, "crochetage", "Crochetage.");
                                AddMenuItem(menu, "vol", "Vol d'argent/voiture.");
                                AddMenuItem(menu, "nuisances", "Nuisances sonores.");
                                AddMenuItem(menu, "insultes", "Insultes.");
                                AddMenuItem(menu, "ordre", "Refus d'obtempérer.");
                                AddMenuItem(menu, "intrusion", "Intrusion.");
                                AddMenuItem(menu, "tir", "Tir dans la rue.");
                                AddMenuItem(menu, "garde", "Garde à vue.");
                                AddMenuItem(menu, "evasion", "Tentative d'évasion.");
                                AddMenuItem(menu, "liberation", "Libérer le joueur.");
                                DisplayMenu(menu, client, MENU_TIME_FOREVER);
                               
                                if (g_booljail[h[client]])
                                {
                                    KillTimer(g_jailtimer[h[client]]);
                                }
                            }
                            else
                            {
                                PrintToChat(client, "%s Vous êtes trop loin pour mettre en prison ce joueur.", LOGO);
                            }
                        }
                        else
                        {
                            PrintToChat(client, "%s Vous ne pouvez pas mettre en prison un policier.", LOGO);
                        }
                    }
                    else
                    {
                        PrintToChat(client, "%s Vous devez être visible pour mettre en prison.", LOGO);
                    }
                }
            }
            else
            {
                PrintToChat(client, "%s Vous n'avez pas accès à cette commande.", LOGO);
            }
        }
        else
        {
            PrintToChat(client, "%s Vous devez être en vie pour emprisonner un joueur.", LOGO);
        }
    }
    return Plugin_Continue;
}


public Menu_Jail(Handle:menu, MenuAction:action, client, param2)
{
    if (action == MenuAction_Select)
    {
        if (IsClientInGame(h[client]))
        {
            if (h[client] != -1 && IsPlayerAlive(h[client]))
            {
                new String:info[64];
                GetMenuItem(menu, param2, info, sizeof(info));
               
                if (StrEqual(info, "meurtrep"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour meurtre sur policier.", LOGO);
                    PrintToChat(client, "%s La peine a bien était mise.", LOGO);


                    g_jailtime[h[client]] = 480;
                }
                else if (StrEqual(info, "meurtrec"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour meurtre sur civil.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);


                    g_jailtime[h[client]] = 240;
                }
                else if (StrEqual(info, "tentative"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour tentative de meurtre.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);


                    g_jailtime[h[client]] = 120;
                }
                else if (StrEqual(info, "crochetage"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour crochetage.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);
                   
                    g_jailtime[h[client]] = 60;
                }
                else if (StrEqual(info, "vol"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour vol.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);
                   
                    g_jailtime[h[client]] = 120;
                }
                else if (StrEqual(info, "nuisances"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour nuisances sonores.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);
                   
                    g_jailtime[h[client]] = 120;
                }
                else if (StrEqual(info, "insultes"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour insultes.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);
                   
                    g_jailtime[h[client]] = 240;
                }
                else if (StrEqual(info, "ordre"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour refus d'obtempérer.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);


                    g_jailtime[h[client]] = 120;
                }
                else if (StrEqual(info, "intrusion"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour intrusion.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);


                    g_jailtime[h[client]] = 180;
                }
                else if (StrEqual(info, "tir"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour tir dans la rue.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);


                    g_jailtime[h[client]] = 80;
                }
                else if (StrEqual(info, "garde"))
                {
                    PrintToChat(h[client], "%s Vous avez été mis en garde à vue.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);
                   
                    g_jailtime[h[client]] = 30;
                }
                else if (StrEqual(info, "evasion"))
                {
                    PrintToChat(h[client], "%s Vous avez été emprisonné pour tentative d'évasion.", LOGO);
                    PrintToChat(client, "%s La peine a bien été mise.", LOGO);
                   
                    g_jailtime[h[client]] = 300;
                }
                else if (StrEqual(info, "liberation"))
                {
                    g_jailtime[h[client]] = 5;
                }
                CreateTimer(1.0, Timer_Setjail, h[client]);
            }
        }
    }
}


public Action:Timer_Setjail(Handle:timer, any:client)
{
    g_booljail[client] = true;
    g_jailtimer[client] =  CreateTimer(1.0, Jail_Raison, client, TIMER_REPEAT);
}




public Action:Jail_Raison(Handle:timer, any:client)
{
    if (client > 0 && client <= MaxClients)
    {
        if (IsClientInGame(client))
        {
            if (g_jailtime[client] > 0)
            {
                g_jailtime[client] -= 1;
           
                if (g_jailtime[client] == 0)
                {
                    KillTimer(g_jailtimer[client]);
                   
                    PrintToChat(client, "%s Vous avez été libéré de prison.", LOGO);
                   
                    SetClientListeningFlags(client, VOICE_NORMAL);
                   
                    switch (GetRandomInt(1, 3))
                    {
                        case 1:
                        {
                            TeleportEntity(client, Float:{ -2355.381103, -834.583129, 0.031250 }, NULL_VECTOR, NULL_VECTOR);
                        }
               
                        case 2:
                        {
                            TeleportEntity(client, Float:{ -4798.882324, 3086.674316, -7.968750 }, NULL_VECTOR, NULL_VECTOR);
                        }
               
                        case 3:
                        {
                            TeleportEntity(client, Float:{ -586.247192, 1868.256347, -6.999988 }, NULL_VECTOR, NULL_VECTOR);
                        }
               
                    }
                   
                    g_IsInJail[client] = 0;
                    g_jailtime[client] = 0;
                   
                    g_booljail[client] = false;
                }
            }
        }
    }
}


public Action:Jail_Return(Handle:timer, any:client)
{
    if (IsClientInGame(client))
    {
        if (g_jailtime[client] > 0)
        {
            g_jailtime[client] -= 1;
           
            g_boolreturn[client] = true;
           
            if (g_jailtime[client] == 0)
            {
                g_IsInJail[client] = 0;
                g_jailtime[client] = 0;
               
                PrintToChat(client, "%s Vous avez été libéré de prison.", LOGO);
               
                switch (GetRandomInt(1, 3))
                {
                    case 1:
                        {
                            TeleportEntity(client, Float:{ -2355.381103, -834.583129, 0.031250 }, NULL_VECTOR, NULL_VECTOR);
                        }
               
                        case 2:
                        {
                            TeleportEntity(client, Float:{ -4798.882324, 3086.674316, -7.968750 }, NULL_VECTOR, NULL_VECTOR);
                        }
               
                        case 3:
                        {
                            TeleportEntity(client, Float:{ -586.247192, 1868.256347, -6.999988 }, NULL_VECTOR, NULL_VECTOR);
                        }
           
                }
                KillTimer(g_jailreturn[client]);
               
                g_boolreturn[client] = false;
            }
        }
    }
}


public Action:Command_Jaillist(client, args)
{
    if (IsClientInGame(client))
    {
        if (IsPlayerAlive(client))
        {
            if (GetClientTeam(client) == 3)
            {
                ShowPrisonner(client);
               
                return Plugin_Handled;
            }
            else
            {
                PrintToChat(client, "%s Vous n'avez pas accès à cette commande.", LOGO);
            }
        }
        else
        {
            PrintToChat(client, "%s Vous devez être en vie.", LOGO);
        }
    }
    return Plugin_Continue;
}


ShowPrisonner(client)
{
    if(client > 0 && client <= MaxClients && !IsFakeClient(client))
    {
        decl String:sMenuText[64];
        sMenuText[0] = '\0';
       
        new Handle:menu = CreateMenu(Menu_Prisonnier);
        SetMenuTitle(menu, "Liste des prisonniers");
        SetMenuExitButton(menu, true);
       
        AddPrisonniers(menu);
       
        DisplayMenu(menu, client, MENU_TIME_FOREVER);
    }
}


public AddPrisonniers(Handle:menu)
{
    decl String:user_id[12];
    decl String:name[MAX_NAME_LENGTH];
    decl String:display[MAX_NAME_LENGTH+15];
   
    for (new i = 1; i <= MaxClients; i++)
    {
        if (IsClientInGame(i) && g_jailtime[i] > 0)
        {
            IntToString(GetClientUserId(i), user_id, sizeof(user_id));
               
            GetClientName(i, name, sizeof(name));
               
            Format(display, sizeof(display), "%s => %i", name, g_jailtime[i]);
   
            AddMenuItem(menu, user_id, display, ITEMDRAW_DISABLED);
        }
    }
}


public Menu_Prisonnier(Handle:menu, MenuAction:action, client, param2)
{
    if (action == MenuAction_End)
    {
        CloseHandle(menu);
    }
}


Viewing all articles
Browse latest Browse all 5196