Quote:
Originally Posted by little_froy
the issue is "give" is a cheat command, you have to enable cheats on server or remove "FCVAR_CHEAT" the flag from the command.
however, there is a better solution:
#include <sdktools> and use its "GivePlayerItem"
https://sm.alliedmods.net/new-api/sd...GivePlayerItem
|
is this how it is?
#include <sourcemod>
#include <sdktools>
new const String:g_items[][] = {
"weapon_rifle_m60",
"sniper_awp",
"weapon_grenade_launcher"
};
void GiveWeaponToPlayer(int client, const char[] weapon)
{
GivePlayerItem(client, weapon);
}
public Action:Command_Ruleta(client, args)
{
if (IsClientInGame(client) && IsPlayerAlive(client))
{
if (GetRandomInt(1, 2) == 1) // 50% de probabilidad de tener suerte
{
int index = GetRandomInt(0, sizeof(g_items) - 1);
GiveWeaponToPlayer(client, g_items[index]);
PrintToChat(client, "¡Hoy tienes suerte! Has ganado un %s.", g_items[index]);
}
else
{
PrintToChat(client, "¡No tienes suerte hoy! Inténtalo de nuevo más tarde.");
}
}
return Plugin_Handled;
}
public void OnPluginStart()
{
RegConsoleCmd("sm_ruleta", Command_Ruleta, "Activa la ruleta de la suerte para obtener un arma.");
}