ummm why does this stop?
#1

Код:
stock ModVeh(playerid)
{
	new q[64];
	mysql_debug(1);
	format(q,128,"SELECT `1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`,`13` FROM vehs WHERE Name='%s'",getname(playerid));
	mysql_query(q);
	mysql_store_result();
	mysql_fetch_row_format(q,"|");
	new cmod[13][32];
	explode(q,cmod,"|");
	AddVehicleComponent(tvid[playerid],strval(cmod[0]));
	AddVehicleComponent(tvid[playerid],strval(cmod[1]));
	AddVehicleComponent(tvid[playerid],strval(cmod[2]));
	AddVehicleComponent(tvid[playerid],strval(cmod[3]));
	AddVehicleComponent(tvid[playerid],strval(cmod[4]));
	AddVehicleComponent(tvid[playerid],strval(cmod[5]));
	AddVehicleComponent(tvid[playerid],strval(cmod[6]));
	AddVehicleComponent(tvid[playerid],strval(cmod[7]));
	AddVehicleComponent(tvid[playerid],strval(cmod[8]));
	AddVehicleComponent(tvid[playerid],strval(cmod[9]));
	AddVehicleComponent(tvid[playerid],strval(cmod[10]));
	AddVehicleComponent(tvid[playerid],strval(cmod[11]));
	AddVehicleComponent(tvid[playerid],strval(cmod[12]));
	printf("%d",cmod[4]);
	mysql_free_result();
	mysql_debug(0);
	return 1;
}
something wrong? when i debuged the mysql part the components are saved in the DB and are fetched when the ModVeh() is called. but i think add vehicle component is stopping it any idea why?


EDIT:

Better code:
pawn Код:
stock ModVeh(playerid)
{
    new q[64];
    format(q,128,"SELECT `1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`,`13` FROM vehs WHERE Name='%s'",getname(playerid));
    mysql_query(q);
    mysql_store_result();
    mysql_fetch_row_format(q,"|");
    new cmod[13][32];
    explode(q,cmod,"|");
    for(new i=0;i<13;i++)
    {
        if(strval(cmod[i]) == 0) { printf("%d",strval(cmod[i])); continue; }
        printf("%d",strval(cmod[i]));
        AddVehicleComponent(tvid[playerid],strval(cmod[i]));
    }
    mysql_free_result();
    print("modded");
    return 1;
}
hmm it seems to crash even with a correct id
Reply
#2

What does the mysql_log say? My guess: Your string is too short to store the entire result, thus bugging up.
Reply
#3

oh lol idk it say it successfully executed it in log so i didnt care. but it turned out to be like it was changing the vehicle id to 118 for some reason. i changed the size to 12 8and it worked. anyway thanks for trying
Reply
#4

sry for DP but can you tell me how to calculate the required lenght? like how did you know the string was too short etc
Reply
#5

Common sense and basic mathematics...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)