View Single Post
  #1  
Old 01-05-2003, 06:24 PM
mByte
Hill Giant
 
Join Date: Feb 2002
Posts: 206
Default strncpy question

I am working on a small side project for me to add npc's just by being in the world.

I am saving them to the database but now I want to remove the 000's

can somebody over look this code tell me what is wrong and someway to fix it.

Code:
void Database::SaveSpawn(const char* s1, int8 s2, int16 s3, int8 s4, sint32 s5, int8 s6, int8 s7, int8 s8, float s9, int8 s10)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
	int snl = strlen(s1)-3;
	char snbuff[64];
	char *query = 0;
	int32 affected_rows = 0;
    MYSQL_RES *result;
    MYSQL_ROW row;

	if(strstr(s1, "00") != 0){
		strncpy(snbuff,s1,snl);
	}

	char* sqlQuery = "INSERT INTO npc_types (name, level, race, class, hp, gender, texture, helmtexture, size, social) values('%s','%i','%i','%i','%i','%i','%i','%i','%f','%i')";

	RunQuery(query, MakeAnyLenString(&query, sqlQuery, snbuff,s2,s3,s4,s5,s6,s7,s8,s9,s10));
	delete[] query;
}
npc name being passed is 'hot000'

It is removing the three 000's but replacing with this other crap any tips?
[code]
hot
__________________
mByte
Reply With Quote