Help Please
#1

ok people can someone help me with this bit of code,it would be much appreciated
Code:
CMD:myveh(playerid, params[])
{
    new Query[300], pname[24], vID;
    GetPlayerName(playerid, pname, 24);
    format(Query, sizeof(Query),"SELECT vID FROM `vehicles` WHERE `vOwner` = '%s' ", pname);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0) {
        while(mysql_fetch_row(Query)) {
            sscanf(Query, "p<|>i",vID);
//			printf("VID:\t\t%i", vID);
            for(new i=1;i<MAX_VEHICLES;i++) {
                new iMsg[128];
                if(strmatch(vInfo[OwnedVeh(i)][vOwner], pName(playerid))) {
                    format(iMsg,sizeof(iMsg), ""#CRED">"#CORANGE"'%s' "#CDGREEN"You Own Model:"#CORANGE"%i"#CDGREEN " CarID:"#CORANGE"%i"#CRED"<",pName(playerid),vInfo[OwnedVeh(i)],vID);
                    SendClientMessage(playerid,-1,iMsg);
                }
            }
        }
        mysql_free_result();
    }
    return 1;
}
And this is what im getting

but i have been trying to get it to show like this

can anyone help me please
Reply
#2

try to add SendClientMessage(playerid,-1,iMsg); out of loop... something like that:

pawn Code:
CMD:myveh(playerid, params[])
{
    new Query[300], pname[24], vID;
    GetPlayerName(playerid, pname, 24);
    format(Query, sizeof(Query),"SELECT vID FROM `vehicles` WHERE `vOwner` = '%s' ", pname);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0) {
        while(mysql_fetch_row(Query)) {
            sscanf(Query, "p<|>i",vID);
//          printf("VID:\t\t%i", vID);
            for(new i=1;i<MAX_VEHICLES;i++) {
                new iMsg[128];
                if(strmatch(vInfo[OwnedVeh(i)][vOwner], pName(playerid))) {
                    format(iMsg,sizeof(iMsg), ""#CRED">"#CORANGE"'%s' "#CDGREEN"You Own Model:"#CORANGE"%i"#CDGREEN " CarID:"#CORANGE"%i"#CRED"<",pName(playerid),vInfo[OwnedVeh(i)],vID);
                }
                SendClientMessage(playerid,-1,iMsg);
            }
        }
        mysql_free_result();
    }
    return 1;
}
i dont now is it going to works.. but try
Reply
#3

Yer cheers for that,but it doesnt send SendClientMessage part,it seems to read the model numbers twice,but reads the veh id once,but not matter what i have tried,i cannot get it to show model then the id for that vehicle and the others you would own
Reply
#4

just thought i would bump this and see if anyone has any ideas
Reply
#5

hey, I am not sure why you saved the vehicleid in mysql since it is total useless there

To get your wanted result you only need
pawn Code:
CMD:myveh(playerid, params[]) {
    new
        i = 0,
        iMsg[128],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof name);
    while(++i != MAX_VEHICLES) {
        if(strmatch(vInfo[OwnedVeh(i)][vOwner], name)) { // strmatch ?
            format(iMsg,sizeof(iMsg), #CRED ">" #CORANGE "'%s' "#CDGREEN "You Own Model:" #CORANGE "%i" #CDGREEN " CarID:" #CORANGE "%i" #CRED "<", name, vInfo[OwnedVeh(i)], i);
            SendClientMessage(playerid, -1, iMsg);
        }
    }
    return 1;
}
Reply
#6

If I knew MySQL I would gladly help you out, but sadly I don't. But trying the above coding, they should work fine for you as I'm reading threw them.
Reply
#7

Cheer Nero_3D,that worked a treat,i have just started to use mysql,so im still on a long learning curve,the more i learn,the more i forget

Brandon cheers for your input,thats is the reason i have started to try and understand mysql and how it works,because i am trying to make a complete mysql gamemode using mysql in my spare time,so due to my available spare time,i should finish in 2015 lol
Reply
#8

Quote:
Originally Posted by fubar
View Post
Cheer Nero_3D,that worked a treat,i have just started to use mysql,so im still on a long learning curve,the more i learn,the more i forget

Brandon cheers for your input,thats is the reason i have started to try and understand mysql and how it works,because i am trying to make a complete mysql gamemode using mysql in my spare time,so due to my available spare time,i should finish in 2015 lol
Same here, I have been reading tutorials every single day so I can understand how MySQL Functions...eventually...you (and myself) will understand the way MySQL function, possibly helping other with it some day.
Reply
#9

Yer i seem to have got the understanding of mysql,but now i have forgotten how to use pawno

Nero,in case you where wondering what 'strmatch' was used for.....
Code:
stock strmatch(const String1[], const String2[]){
	if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1))){
		return true;}
	else{
		return false;}}
it is surposed to check 2 string to see if they match(i think anyways,but doesnt work very well for me,but thats just me)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)