Raised This Month: $51 Target: $400
 12% 

giveplayeritem(client,weapon) doesn't work any other ways?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pr0mers
Junior Member
Join Date: May 2020
Old 07-21-2021 , 17:32   giveplayeritem(client,weapon) doesn't work any other ways?
Reply With Quote #1

I am trying to make a plugin that applies skin to every gun taken from floor by giving them with giveplayeritem

(aim_redline in guns in the floor has no skin.i can make 2 ifs giveplayeritem(client,"weapon_m4a1") giveplayeritem(client,"weapon_ak47") but in general it doesn't work without if ing every gun)

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
	HookEvent("item_pickup", Event_OnItemPickup);
}
int aldi = 0;
public Event_OnItemPickup(Handle:event, const String:name[], bool:dontBroadcast)
{
	if(aldi==1){
		aldi = 0;
		return;
	}
	new client = GetClientOfUserId(GetEventInt( event, "userid"));
	decl String:sItem[100];
	GetEventString(event, "item", sItem, sizeof(sItem));	
	//PrintToChatAll("%s", sItem);
	new silah = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY);
	PrintToChatAll("silah1: %s", sItem);
	
	if(silah != -1){
		RemovePlayerItem(client, silah);
	}
	char silah2[256]
	Format(silah2, sizeof(silah2), "weapon_%s", sItem);
	PrintToChatAll("silah2: %s", silah2);
	//GivePlayerItem(client,silah2);//--------what should i do here
	aldi = 1;
	
}
it says argument type mismatch
__________________
My Steam
My Youtube Channel
My Github
My Discord : pr0mers#0369
-I always write unnecessary plugins-
(you can tell me better ways to do something, thank you)

Last edited by pr0mers; 07-21-2021 at 17:59. Reason: forgot to add error
pr0mers is offline
little_froy
Senior Member
Join Date: May 2021
Old 07-21-2021 , 20:42   Re: giveplayeritem(client,weapon) doesn't work any other ways?
Reply With Quote #2

alright, my fault.
please show the error or log post.

Last edited by little_froy; 07-22-2021 at 04:53.
little_froy is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 07-29-2021 , 11:03   Re: giveplayeritem(client,weapon) doesn't work any other ways?
Reply With Quote #3

Hey there! After looking to your code, I did some little improvements
Also, your error was where you were creating the variable silah2, it was missing a semicolon at the end of the line

Here it is (untested):
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
    
HookEvent("item_pickup"Event_OnItemPickup);
}
int aldi 0;
public 
Event_OnItemPickup(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
aldi == 1) {
        
aldi 0;
        return;
    }
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
char sItem[100];
    
GetEventString(event"item"sItemsizeof(sItem));
    
//PrintToChatAll("%s", sItem);
    
int silah GetPlayerWeaponSlot(client0); //0 = primary | 1 = pistols | 3 = knife or zeus | 4 = utility | 5 = bomb
    
PrintToChatAll("silah1: %s"sItem);
    
    
/*if(silah != -1){
        RemovePlayerItem(client, silah);
    }*/
    
if (IsValidEntity(silah)) {
        
RemovePlayerItem(clientsilah);
    }
    
char silah2[256];
    
Format(silah2sizeof(silah2), "weapon_%s"sItem);
    
PrintToChatAll("silah2: %s"silah2);
    
GivePlayerItem(clientsilah2);
    
aldi 1;
    

__________________
SpirT is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode