1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
int getplayers (int player, int pos, int team, int side, int t){
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
//#################################################################
//######################## MySQL ##################################
//#################################################################
[...](as before..]
/*
###########################################################
######################## Spieler ##########################
###########################################################
*/
char abfrage[300];
int mooh=sprintf(abfrage,"SELECT * FROM player WHERE id='%d'", player);
printf("%s",abfrage);
mysql_query(connect,abfrage);
int rc;
unsigned int i = 0;
res_set = mysql_store_result(connect);
unsigned int numrows = mysql_num_rows(res_set);
int vert=4;
int mf=4;
int st=2;
int x=0;
// This while is to print all rows and not just the first row found,
while ((row = mysql_fetch_row(res_set)) !=NULL)
{
player[t].pid = atoi(row[0]);
player[t].foot = atoi(row[4]);
player[t].name = row[3];
player[t].team = team; //atoi(row[11]);
//player[t].movetox=zufallx();
//player[t].movetoy=zufally();
player[t].frische = atoi(row[30]);
player[t].moral = atoi(row[29]);
player[t].kondition = atoi(row[13]);
player[t].skill = atoi(row[48]);
player[t].form = atoi(row[61]);
player[t].passspiel = atoi(row[14]);
player[t].zweikampf = atoi(row[15]);
player[t].technik = atoi(row[16]);
player[t].schnell = atoi(row[17]);
player[t].kopfb = atoi(row[31]);
player[t].schusskr = atoi(row[32]);
player[t].schussg = atoi(row[33]);
player[t].spielint = atoi(row[34]);
player[t].stellsp = atoi(row[35]);
player[t].t_reflex = atoi(row[36]);
player[t].t_parade = atoi(row[37]);
player[t].t_luft = atoi(row[38]);
player[t].t_heraus = atoi(row[39]);
player[t].t_ballsich = atoi(row[40]);
player[t].side = side;
player[t].vert = vert;
player[t].mf = mf;
player[t].st = st;
player[t].posnum = x;
player[t].grosse=atoi(row[112]);
player[t].aura = (atoi(row[34]) + atoi(row[35]) + atoi(row[17]) + atoi(row[15]))/40;
player[t].maxpass = ((atoi(row[32]) + (2*(atoi(row[14]))) + atoi(row[33]) + atoi(row[34]) + atoi(row[16]))/12)+10;
player[t].pos = atoi(row[18]);
player[t].standard=ceil((atoi(row[33])+atoi(row[32])+atoi(row[16])+atoi(row[14]))/40);
printf("%d",player[t].standard);
printf("|%s|(%s)[%s][%s cm]\n", row[3], row[18],row[11], row[112]);
if(side==1){
if(player[t].pos==1){
player[t].posx=11;
}
else if(player[t].pos==2){
player[t].posx=25;
}
else if(player[t].pos==3){
player[t].posx=45;
}
else{
player[t].posx=50;
}
}else if(side==2){
if(atoi(row[18])==1){
player[t].posx=89;
}
else if(atoi(row[18])==2){
player[t].posx=75;
}
else if(atoi(row[18])==3){
player[t].posx=55;
}
else if(atoi(row[18])==4){
player[t].posx=50;
}
}
rc = pthread_create(&threads[t], &attr, poschecks, (void *) &player[t]);
t++;
x++;
}
printf("--------------\n");
mysql_close(connect); // Close and shutdown
return t;
}
|