So I have a plugin for donators that allows them to buy any weapon from the opposite team.
A slight problem I'm having while testing is that let's say I'm a terrorist. I have an AK, but issues the command to buy an M4. The M4 just drops to my feet while I still have the AK. I want to have the AK dropped and the M4 in the player's hands.
If I'm gathering what I've searched correctly, I need to use SDKHooks to force a weapon to be dropped, correct? In either case, I could use the help. Someone else wrote it for me as a paid plugin, but he has been hard to reach lately.
PHP Code:
if(StrEqual(info, "elite"))
{
new currentmoney = GetEntData(client, MoneyOffset);
if(currentmoney < ELITE_COST)
{
PrintToChat(client, "[SM] You do not have enough money.");
return;
}
SetEntData(client, MoneyOffset, currentmoney - ELITE_COST, 4, true);
GivePlayerItem(client, "weapon_elite");
}
if(StrEqual(info, "mac10"))
{
new currentmoney = GetEntData(client, MoneyOffset);
if(currentmoney < MAC10_COST)
{
PrintToChat(client, "[SM] You do not have enough money.");
return;
}
SetEntData(client, MoneyOffset, currentmoney - MAC10_COST, 4, true);
GivePlayerItem(client, "weapon_mac10");
}
__________________
Quote:
skywalker: I have cs source client 5 how to upgrade to client 7
BAILOPAN: oh
I'm guessing index is just a name you gave the variable? Would I name one "Primary" and another "Secondary" or is the way I have it right?
No, you cannot create 2 variables with the same name in the same (i think it's called scope).
Your example should look like this, much shorter and reusable:
No, you cannot create 2 variables with the same name in the same (i think it's called scope).
Your example should look like this, much shorter and reusable:
if you're not bothered about removing the old weapon you can use the EquipPlayerWeapon native with the new weapon to force a player equip it and drop their old one.
if you're not bothered about removing the old weapon you can use the EquipPlayerWeapon native with the new weapon to force a player equip it and drop their old one.
So instead of just giving the weapon I would equip it instead?
__________________
Quote:
skywalker: I have cs source client 5 how to upgrade to client 7
BAILOPAN: oh
No, you cannot create 2 variables with the same name in the same (i think it's called scope).
Your example should look like this, much shorter and reusable:
new Handle:sm_advcom_cmd = INVALID_HANDLE; new MoneyOffset;
public Plugin:myinfo = { name = "AoA VIP Pack 1", author = "Bloodlvst", description = "Commands for premium donors", version = "1.0", url = "http://www.sourcemod.net/" };
public OnPluginStart() { sm_advcom_cmd = CreateConVar("sm_advcom_cmd", "1", "Whether to broadcast the command when it's typed. Default false. (1 or 0)"); RegConsoleCmd("sm_buy", GiveCommand); MoneyOffset = FindSendPropOffs("CCSPlayer", "m_iAccount"); }
public Action:GiveCommand(client, args) { if( !(GetUserFlagBits(client) & FLAG) && !(GetUserFlagBits(client) & ADMFLAG_ROOT) ) { PrintToChat(client, "[SM] You do not have permission to access this command."); return Plugin_Handled; } new team = GetClientTeam(client); if(team == 1 || team == 0) { PrintToChat(client, "[SM] You need to be on a team to access this command."); return Plugin_Handled; } if (args < 1) { if(team == 2) { BuildTMenu(client); return Plugin_Handled; } else if(team == 3) { BuildCTMenu(client); return Plugin_Handled; } } else { decl String:weapon[20]; GetCmdArg(1, weapon, sizeof(weapon));