Hallo Liebe Breadfish user,
Ich wolte mit dem mysql tutorial von (Maddin | ) ein Biz system machen .
leider geht das nicht wirklich so :
- Es wird garnix erstellt.
Ich bitte um hilfe .
Unter OnGameModInit :
for(new h = 0; h < sizeof(BizInfo); h++)
{
new string3[128];
if(BizInfo[h][pBizOwned] == 0)
{
format(string3, sizeof(string3), "Zum Verkauf\n Name: %s\nPreis: %d Euro\n",BizInfo[h][pBizName], BizInfo[h][pBizPreis]);
BizInfo[h][pBizLabelID] = Create3DTextLabel(string3,COLOR_RED,BizInfo[h][pBizPosX], BizInfo[h][pBizPosY], BizInfo[h][pBizPosZ]+1,22.0,0,0);
AddStaticPickup(1272, 2, BizInfo[h][pBizPosX], BizInfo[h][pBizPosY], BizInfo[h][pBizPosZ]);
}
if(BizInfo[h][pBizOwned] == 1)
{
format(string3, sizeof(string3), "Besitzer: %s\nBizteilhaber: %s",BizInfo[h][pBizOwner], BizInfo[h][pBizCoOwner]);
BizInfo[h][pBizLabelID] = Create3DTextLabel(string3,COLOR_RED,BizInfo[h][pBizPosX], BizInfo[h][pBizPosY], BizInfo[h][pBizPosZ]+1,22.0,0,0);
AddStaticPickup(1239, 2, BizInfo[h][pBizPosX], BizInfo[h][pBizPosY], BizInfo[h][pBizPosZ]);
}
}
stock LoadBiz()
{
for(new h = 0; h < sizeof(BizInfo); h++)
{
//BizInfo[i][] = mysql_GetIntBiz("biz", ""); || BizInfo[i][] = mysql_GetFloatBiz("biz", "");
BizInfo[h][pBizOwner] = mysql_GetIntBiz("biz", "BizOwner", "BizID" , BizInfo[h][pBizID]);
BizInfo[h][pBizCoOwner] = mysql_GetIntBiz("biz", "BizCoOwner", "BizID" , BizInfo[h][pBizID]);
BizInfo[h][pBizOwned] = mysql_GetIntBiz("biz","BizGeKauft", "BizID" , BizInfo[h][pBizID]);
BizInfo[h][pBizName] = mysql_GetIntBiz("biz", "BizName", "BizID" , BizInfo[h][pBizID]);
BizInfo[h][pBizPreis] = mysql_GetIntBiz("biz", "BizPreis", "BizID" , BizInfo[h][pBizID]);
BizInfo[h][pBizPosX] = mysql_GetFloatBiz("biz", "BizPosX", "BizID" , BizInfo[h][pBizID]);
BizInfo[h][pBizPosY] = mysql_GetFloatBiz("biz", "BizPosY", "BizID" , BizInfo[h][pBizID]);
BizInfo[h][pBizPosZ] = mysql_GetFloatBiz("biz", "BizPosZ", "BizID" , BizInfo[h][pBizID]);
}
return 1;
}
stock SaveBiz()
{
for(new h = 0; h < sizeof(BizInfo); h++)
{
// mysql_SetInt("biz", "", BizInfo[i][]); || mysql_SetFloatBiz("biz", "", BizInfo[i][]);
mysql_SetIntBiz("biz", "BizOwner", BizInfo[h][pBizOwner], "BizID" , BizInfo[h][pBizID]);
mysql_SetIntBiz("biz", "BizCoOwner", BizInfo[h][pBizCoOwner], "BizID" , BizInfo[h][pBizID]);
mysql_SetIntBiz("biz", "BizGeKauft", BizInfo[h][pBizOwned], "BizID" , BizInfo[h][pBizID]);
mysql_SetIntBiz("biz", "BizName", BizInfo[h][pBizName], "BizID" , BizInfo[h][pBizID]);
mysql_SetIntBiz("biz", "BizPreis", BizInfo[h][pBizPreis], "BizID" , BizInfo[h][pBizID]);
mysql_SetFloatBiz("biz", "BizPosX", BizInfo[h][pBizPosX], "BizID" , BizInfo[h][pBizID]);
mysql_SetFloatBiz("biz", "BizPosY", BizInfo[h][pBizPosY], "BizID" , BizInfo[h][pBizID]);
mysql_SetFloatBiz("biz", "BizPosZ", BizInfo[h][pBizPosZ], "BizID" , BizInfo[h][pBizID]);
}
return 1;
}
stock mysql_CheckBiz()
{
new Query[128];
new id[20];
mysql_real_escape_string(id, id);
format(Query, sizeof(Query), "SELECT * FROM biz WHERE BizID = '%d'", id);
mysql_query(Query);
mysql_store_result();
return mysql_num_rows();
}
// =========== GET ===================
stock mysql_GetFloatBiz(Table[], Field[], Where[], Is[])
{
new query[128], Float:sqlfloat;
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT %s FROM %s WHERE %s = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
mysql_fetch_float(sqlfloat);
mysql_free_result();
return sqlfloat;
}
stock mysql_GetIntBiz(Table[], Field[], Where[], Is[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT %s FROM %s WHERE %s = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
new sqlint = mysql_fetch_int();
mysql_free_result();
return sqlint;
}
// ==================== SET================================
stock mysql_SetFloatBiz(Table[], Field[], Float:To, Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE %s SET %s = '%.1f' WHERE %s = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock mysql_SetIntBiz(Table[], Field[], To, Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE %s SET %s = '%d' WHERE %s = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
Könnt ihr mir helfen weil es wird garnix erstellt ?
Bitte um hilfe