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

Not Working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 05-02-2012 , 14:41   Not Working
Reply With Quote #1

Im trying to do something with my "Bunnyhop Commands" Plugin.
Code:
new tele_saved[MAXPLAYERS+1];
new Float:checkpoint[MAXPLAYERS+1][3];

	RegConsoleCmd("sm_save", Command_save, "Saving a Checkpoint on The Client Position.");
	RegConsoleCmd("sm_tele", Command_tele, "Teleport to your Saved Checkpoint.");
	RegConsoleCmd("sm_s", Command_save, "Saving a Checkpoint on The Client Position.");
	RegConsoleCmd("sm_t", Command_tele, "Teleport to your Saved Checkpoint.");

public Action:Command_save(client, args)
{
	GetEntPropVector(client, Prop_Send, "m_vecOrigin", checkpoint[client]);
	tele_saved[client] = 1;
	PrintToChat(client, "\x04[SM]\x01 CheckPoint Saved.");
}

public Action:Command_tele(client, args)
{
	if(checkpoint = true)
	{
		TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
		PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint.");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint First, Type !s/!save for that.)");
	}
}
Error:
PHP Code:
/groups/sourcemod/upload_tmp/textHwQcDO.sp(253) : warning 211possibly unintended assignment
/groups/sourcemod/upload_tmp/textHwQcDO.sp(253) : error 047: array sizes do not match, or destination array is too small 
__________________
retired

Last edited by shavit; 05-02-2012 at 14:41.
shavit is offline
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 05-02-2012 , 14:49   Re: Not Working
Reply With Quote #2

Are you sure you posted the part of code which produces errors? Because I what's wrong about this piece.
Also, using PHP tag in first case and CODE in second would be more appropriate.
__________________
Lord Canistra is offline
extrospect
Member
Join Date: Aug 2009
Old 05-02-2012 , 15:24   Re: Not Working
Reply With Quote #3

You're doing an assignment operation (A = B) instead of a comparison operation (A == B) in this if statement:

Code:
if(checkpoint = true)
{
	TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
	PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint.");
}
else
{
	PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint First, Type !s/!save for that.)");
}
You are also failing to index the checkpoint array, but I believe, from the code you posted, you actually want to be checking the tele_saved array not the checkpoint array - the fixed code would be:

Code:
if(tele_saved[client] == 1)
{
	TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
	PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint.");
}
else
{
	PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint First, Type !s/!save for that.)");
}
Also, it would probably be a good idea to tag the tele_saved array as 'bool:' and populate it with falses by default:
Code:
new bool:tele_saved[MAXPLAYERS+1] = { false, ... };
Then you can change this line for type clarity:
Code:
tele_saved[client] = true;
The last two points don't really affect how the code will function but are merely good practice for maintaining clarity on what the various arrays are storing (in this case a boolean).

The complete example would then be:
Code:
new bool:tele_saved[MAXPLAYERS+1] = { false, ... };
new Float:checkpoint[MAXPLAYERS+1][3];

	RegConsoleCmd("sm_save", Command_save, "Saving a Checkpoint on The Client Position.");
	RegConsoleCmd("sm_tele", Command_tele, "Teleport to your Saved Checkpoint.");
	RegConsoleCmd("sm_s", Command_save, "Saving a Checkpoint on The Client Position.");
	RegConsoleCmd("sm_t", Command_tele, "Teleport to your Saved Checkpoint.");

public Action:Command_save(client, args)
{
	GetEntPropVector(client, Prop_Send, "m_vecOrigin", checkpoint[client]);
	tele_saved[client] = true;
	PrintToChat(client, "\x04[SM]\x01 CheckPoint Saved.");
}

public Action:Command_tele(client, args)
{
	if(tele_saved[client])
	{
		TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
		PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint.");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint First, Type !s/!save for that.)");
	}
}

Last edited by extrospect; 05-02-2012 at 15:37.
extrospect is offline
TheAvengers2
BANNED
Join Date: Jul 2011
Old 05-02-2012 , 15:42   Re: Not Working
Reply With Quote #4

Any particular reason for using GetEntPropVector "m_vecOrigin" over GetClientAbsOrigin?

Last edited by TheAvengers2; 05-02-2012 at 15:48.
TheAvengers2 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 05-03-2012 , 04:57   Re: Not Working
Reply With Quote #5

The guy that helped me, take a crabs or w/e is it! [i cant place it because somebody disabled my BBCode]

Quote:
Originally Posted by TheAvengers2 View Post
Any particular reason for using GetEntPropVector "m_vecOrigin" over GetClientAbsOrigin?
What is the different?

Also, im trying to get the menu api to work to update my bhop commands plugin, ive readed the Menu API in the Sourcemod "wiki" and i still got nothing.

Somebody can give me an example of a menu that im setting the title and 6 options and every option will do "return Plugin_Handled;"?
__________________
retired

Last edited by shavit; 05-03-2012 at 05:23.
shavit 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 22:49.


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