[CSS] /sell

Hello,



My code for sell item is good, unless the withdrawal of money to the buyer and adding money to the seller in case the buyer purchases the item Click post title for more details



Can someone fix it?




PHP Code:







#include <sourcemod>
#include <sdktools>
#include "smlib.inc"

new g_offset = -1;

public 
Plugin:myinfo = 
{ 
    
name = "Menu de vente", 
    
author = "Delachambre", 
    
description = "/vendre", 
    
version = "1.0", 
    
url = "http://vip-magnetik.fr" 
};

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_vendre", Command_vendre);
    
    
g_offset = FindSendPropOffs("CCSPlayer", "m_iAccount");
}

public 
Action:Command_vendre(client, args)
{
    if (
Client_HasAdminFlags(client, ADMFLAG_ROOT))
    {
        new 
Handle:menu = CreateMenu(
vente);
        
SetMenuTitle(menu, "Choisis ce que tu veut vendre :");
        
AddMenuItem(menu, "Fumigene", "Fumigene");
        
AddMenuItem(menu, "Flash", "Flash");
        
AddMenuItem(menu, "Grenade", "Grenade");
        
DisplayMenu(menu< /span>, client, 15);
    }
    else
    {
        
PrintToChat(client, "\x02[JailRP] : Vous n'avez pas accès Ã  cette commande");
    }
}

public 
vente(Handle:menu, MenuAction:action, client, param2)
{
    if (
action == MenuAction_Select)
    {
        new&nb sp;
String:info[32];
        
GetMenuItem(menu, param2, info, sizeof(info));
            
        new 
i = GetClientAimTarget(client, true);
            
        new 
Float:entorigin[3], Float:clientent[3];
        
GetEntPropVector(i, Prop_Send, "m_vecOrigin", entorigin);
        
GetEntPropVector(client, Prop_Send, "m_vecOrigin", clientent);
            
        if (
StrEqual(info, "Fumigene"))
        {
            new 
Handle :menu = CreateMenu(ventefumi);
            
SetMenuTitle(menu, "Voulez vous acheté une Fumigene Ã  200$ ?");
            
AddMenuItem(menu, "Oui", "Oui");
            
AddMenuItem(menu, "Non", "Non");
            
DisplayMenu(menu, i
, 15);
        }
        if (
StrEqual(info, "Flash"))
        {
            new 
Handle:menu = CreateMenu(venteflash);
            
SetMenuTitle(menu, "Voulez vous acheté une Flash Ã  250$ ?");
            
AddMenuItem(menu, "Oui", "Oui");
            
AddMenuItem(menu, "Non", "Non");
            
DisplayMenu(menu, i, 15);
        }
        if (
StrEqual(info, "Grenade"))
        {
            new 
Handle:menu = CreateMenu( ventegrenade);
            
SetMenuTitle(menu, "Voulez vous acheté une Grenade Ã  400$ ?");
            
AddMenuItem(menu, "Oui", "Oui");
            
AddMenuItem(menu, "Non", "Non");
            
DisplayMenu(menu, i, 15);
         }
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
}

public 
ventefumi(Handle:menu, MenuAction:action, client, param2)
{
    new 
i = GetClientAimTarget(client, true);
            
    new < /span>Float:entorigin[3], Float:clientent[3];
    
GetEntPropVector(i, Prop_Send, "m_vecOrigin", entorigin);
    
GetEntPropVector(client, Prop_Send, "m_vecOrigin", clientent);
        
    if (
action == MenuAction_Select)
    {
        new 
String:infos[32];
        
GetMenuItem(menu, param2, infos, sizeof(infos));

        if (
StrEqual(infos, "Oui"))
        {
            
PrintToChat(client, "\x04[JailMod] : Vous avez acheté une fumigène a 200$.");
            
GivePlayerItem(
client, "weapon_smokegrenade");
            
DelCash(client, 200);
            
Addcash(i, 200);
        }
        if (
StrEqual(infos, "Non"))
        {
            
PrintToChat(client, "\x04[JailMod] : Vous avez refusé l'achat d'une&nb sp;fumigène a 200$.");
        }
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
}

public 
venteflash(Handle:menu, MenuAction:action, client, param2)
{
    new 
i = GetClientAimTarget(client, true);
        ;     
    new 
Float:entorigin[3], Float:clientent[3];
    
GetEntPropVector(i, Prop_Send, "m_vecOrigin", entorigin);
    
GetEntPropVector(client, Prop_Send, "m_vecOrigin", clientent);
        
    if (
action == MenuAction_Select)
    {
 &nbs p;      new 
String:infoss[32];
        
GetMenuItem(menu, param2, infoss, sizeof(infoss));

        if (
StrEqual(infoss, "Oui"))
        {
            
PrintToChat(client, "\x04[JailMod] : Vous avez acheté une flash a 250$.");
      &n bsp;     
GivePlayerItem(client, "weapon_flashbang");
            
DelCash(client, 250);
            
Addcash(i, 250);
        }
        if (
StrEqual(infoss, "Non"))
        {
            
PrintToChat(client, "\x04[JailMod 3; : Vous avez refusé l'achat d'une flash a 250$.");
        }
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
}

public 
ventegrenade(Handle:menu, MenuAction:action, client, param2)
{
    new 
i = GetClientAimTarget(client, true);
            
    new 
Float:entorigin[3], Float:clientent[3];
    
GetEntPropVector(i, Prop_Send, "m_vecOrigin", entorigin);
    
GetEntPropVector(client, Prop_Send, "m_vecOrigin", clientent);
    
    if (
action == MenuAction_Select)
    {
        new 
String:infosss[32];
        
GetMenuItem(menu, param2, infosss, sizeof(infosss));

        if (
StrEqual(infosss, "Oui"))
        {
            
PrintToChat(client, "\x04[JailMod] : Vous avez acheté une grenade a 400$.");
            
GivePlayerItem(client, "weapon_hegrenade");
            
DelCash(client, 400);
            
Addcash(i, 400);
        }
        if (
StrEqual(infosss, "Non"))
        {
            
PrintToChat(client, "\x04[JailMod] : Vous avez refusé l'achat d'une grenade a 400$.");
        }
    }
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
}

DelCash(client, montant)
{
    new 
current = GetEntData(client, g_offset);
    new 
total;
   ;  if ((
current + montant) > 16000)    total = 16000;
    else                                    
total = (current - montant);
    
    
SetEntData(client, g_offset, total);
}

Addcash(client, montant)
{
  & nbsp; new 
currents = GetEntData(client, g_offset);
    new 
totals;
    if ((
currents + montant) > 16000)    totals = 16000;
    else                                    
totals = (currents + montant);
    
    
SetEntData (client, g_offset, totals);
} 









thanks in advance, sorry for my bad English, i am French.


Orignal From: [CSS] /sell

No comments

Not a single link is allowed to submit in comment :o