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

World not allowed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JanDev
Junior Member
Join Date: Feb 2017
Old 02-22-2017 , 08:17   World not allowed
Reply With Quote #1

I'm pretty new to this forum, but I hope you can help me a bit

So I've modified a little knife plugin for me and my friends on a LAN server and I get some errors.

Code:
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));

	if (GetClientTeam(client) > 1 && !IsPlayerAlive(client))
	{
		return;
	}
	
	new iWeapon = GetPlayerWeaponSlot(client, 2);
	new iItem;
	
	switch(weapon_choose[client]) {
		case 1: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_bayonet");}
		case 2: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_gut");}
		case 3: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_flip");}
		case 4: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_m9_bayonet");}
		case 5: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_karambit");}
		case 6: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_tactical");}
		case 7: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_butterfly");}
		case 8: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_push");}
		case 9: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) 
		{RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_survival_bowie");}
		default: {return;}
	}
	EquipPlayerWeapon(client, iItem);
}
I get the following error (sometimes, I cant meassure when.):

Code:
L 02/21/2017 - 16:00:50: [SM] Exception reported: World not allowed
L 02/21/2017 - 16:00:50: [SM] Blaming: KNIFE.smx
L 02/21/2017 - 16:00:50: [SM] Call stack trace:
L 02/21/2017 - 16:00:50: [SM]   [0] EquipPlayerWeapon
L 02/21/2017 - 16:00:50: [SM]   [1] Line 359, /home/groups/sourcemod/upload_tmp/phpjiKbkU.sp::PlayerSpawn
JanDev is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-22-2017 , 09:13   Re: World not allowed
Reply With Quote #2

It means you are trying to use index 0, which is world
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
JanDev
Junior Member
Join Date: Feb 2017
Old 02-22-2017 , 10:13   Re: World not allowed
Reply With Quote #3

Quote:
Originally Posted by friagram View Post
It means you are trying to use index 0, which is world
So I need to check if iItem = 0 ?
JanDev is offline
JanDev
Junior Member
Join Date: Feb 2017
Old 02-22-2017 , 15:51   Re: World not allowed
Reply With Quote #4

Quote:
Originally Posted by friagram View Post
It means you are trying to use index 0, which is world
I didn't quite catch what you trying to say ... maybe try to explain it a bit better
JanDev is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-22-2017 , 16:04   Re: World not allowed
Reply With Quote #5

Just like he says check to see if iWeapon is greater than 0 (or even better greater than MaxClients.
Also you might want to rethink that switch statement either into a function or a string array. Usually if there is repeated code then you are doing something wrong.
Mitchell is offline
JanDev
Junior Member
Join Date: Feb 2017
Old 02-22-2017 , 16:51   Re: World not allowed
Reply With Quote #6

Quote:
Originally Posted by Mitchell View Post
Just like he says check to see if iWeapon is greater than 0 (or even better greater than MaxClients.
Also you might want to rethink that switch statement either into a function or a string array. Usually if there is repeated code then you are doing something wrong.
So theoretical its this ?!:

Code:
if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE && iWeapon > 0)
Of course I will change the code and change/remove the switch. It's just a first version.
JanDev 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 05:08.


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