Help with a command ,for developers

Status
Not open for further replies.
Newbie Spellweaver
Joined
Aug 16, 2012
Messages
55
Reaction score
2
This is my command post create by me
Code:
void postt(int aIndex,char* msg)
{	
	OBJECTSTRUCT * gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
	int PostPrice = GetPrivateProfileInt("Post","PostPrice",5000000,".\\ZYGHY.ini");
	int PostCount = GetPrivateProfileInt("Post","Active",1,".\\ZYGHY.ini");
	int PostLevel = GetPrivateProfileInt("Post","Level",50,".\\ZYGHY.ini");
	if(aIndex <= OBJECT_MIN && aIndex >= OBJECT_MAX)
		return;
	if(aIndex > OBJECT_MAX)
		return;
	char Query[512] = {0};
	wsprintf(Query,"SELECT BanPost FROM Character WHERE Name = '%s'", gObj->Name);
	char *Result = SQL.ReturnString("BanPost",Query);
		if(*Result == 1)
		{
			if(gObj->Level > PostLevel)
				{
					if(gObj->Money < PostPrice)
					{
					MsgNormal(aIndex,"[OnlygMU] :Hey,you don`t have zen for /post!");
					}
					else
					{
						if(PostCount == 1)
						{
						Messages.outYellow(aIndex,"%s:[post]: %s",gObj->Name,msg);
						(gObj->Money -= PostPrice);
						 GCMoneySend(gObj->m_Index, gObj->Money);
						}
						else
						{
						MsgNormal(aIndex,"[OnlygMU] :Hey,/post command disabled!");
						}
					}
				}
				else
				{		
				MsgNormal(aIndex,"[OnlygMU] : You short level to use /post!");
				}  
		}
		else
		{
		MsgNormal(aIndex,"[OnlygMU] : Are you banned on /post !");
		}
}

I try to make a command to block command aforementioned changed in database in collum "BanPost 1 to 0 for a specific player
Code:
void banpost(DWORD gObjId, char *Msg,char Index)
{
	
	OBJECTSTRUCT * gObj = (OBJECTSTRUCT*)OBJECT_POINTER(gObjId);	
	OBJECTSTRUCT * tObj = (OBJECTSTRUCT*)OBJECT_POINTER(Index);
	char Query[512];
	if(gObj->Authority != 32)
	{	
		MsgNormal(gObjId,"[OnlygMU] : Command only for GM's");
		return;	
	}																									   
	wsprintf(Query,"UPDATE Character SET BanPost = 0 WHERE Name = '%s'", tObj->Name);
	SQLExecute(Query);
	SQL.DoQuery(Query);
	Messages.outYellow(gObjId, "[BanPost] %s post banned.", Msg);	
	Messages.outYellow(gObjId, "[BanPost] Was banned by %s.", gObj->Name);
}

And define command in void ChatDataSend(DWORD gObjId,LPBYTE Protocol)

Code:
if(!memcmp(&Protocol[13],"/banpost",strlen("/banpost")))
	{
		banpost(gObjId,(char*)Protocol+13+strlen("/banpost"),(char)Protocol+13+strlen("/banpost"));
	}

I try this but i get a error "error C2065: 'Index' : undeclared identifier"

Code:
if(!memcmp(&Protocol[13],"/banpost",strlen("/banpost")))
	{
		banpost(gObjId,(char*)Protocol+13+strlen("/banpost"),Index);
	}
 
Try this:
Code:
if(!memcmp(&Protocol[13],"/banpost",strlen("/banpost"))) {    banpost(gObjId,(char*)Protocol+13+strlen("/banpost")); }


Code:
if(!memcmp(&Protocol[13],"/banpost",strlen("/banpost")))     
{        
 banpost([COLOR=#0000ff][B]gObjId[/B][/COLOR]);    
 }
 
Last edited:
Upvote 0
Try this:
Code:
if(!memcmp(&Protocol[13],"/banpost",strlen("/banpost"))) {    banpost(gObjId,(char*)Protocol+13+strlen("/banpost")); }

He can't do that, and that because he's function takes 3 arguments.


Code:
if(!memcmp(&Protocol[13],"/banpost",strlen("/banpost")))     
{        
 banpost([COLOR=#0000ff][B]gObjId[/B][/COLOR]);    
 }

error C2660: 'banpost' : function does not take 1 arguments

You already got the solution ..

Code:
if(!memcmp(&Protocol[13],"/banpost",strlen("/banpost"))) 	{ 		banpost(gObjId,(char*)Protocol+13+strlen("/banpost"),(char)Protocol+13+strlen("/banpost")); 	}

You posted it ..
I doubt that you made this command -_-
 
Upvote 0
Just make a copy of post function, and chack if it work. Next modify function body to make all what you need. This work in any situation, when you don't know what to do.
 
Upvote 0
another solution do to this?
I try this but don`t work

Code:
void banpost(DWORD aIndex,char *ChatMSG)
{	
	OBJECTSTRUCT * gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
	char Player[16] = {0};
	char Query[512] = {0};
	if(aIndex <= OBJECT_MIN && aIndex >= OBJECT_MAX)
		return;
	if(aIndex > OBJECT_MAX)
		return;
	if(*ChatMSG <= OBJECT_MIN && *ChatMSG >= OBJECT_MAX)
		return;
	*ChatMSG = gObjByNick(Player);
	wsprintf(Query,"UPDATE Character SET BanPost = 0 WHERE Name = '%s'", *ChatMSG);
	SQLExecute(Query);
	SQL.DoQuery(Query);
	Messages.outYellow(aIndex,"[ItcGamesMU] :%s banned on post by %s!",*ChatMSG,gObj->Name);							
}
 
Upvote 0
Status
Not open for further replies.
Back