PDA

View Full Version : Mysql problem


Tanush123
30/12/2011, 10:53 PM
CMD:oskin(playerid,params[])
{
new oskin1,oskin2;
if(PlayerInfo[playerid][Member] == -255) return 0;
CheckMySQL();
format(str, sizeof(str), "SELECT * FROM orgs WHERE Orgid = '%d'",orgid);
mysql_query(str);
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_fetch_field_row(str,"Skin1"); oskin1 = strval(str);
mysql_fetch_field_row(str,"Skin2"); oskin2 = strval(str);
if(GetPlayerSkin(playerid) == oskin1)
{
SetPlayerSkin(playerid,oskin2);
}
else if(GetPlayerSkin(playerid) == oskin2)
{
SetPlayerSkin(playerid,oskin1);
}
}
mysql_free_result();
return 1;
}
Well nothing happens when i does /oskin? im noob in mysql still so can you guys help

FireCat
30/12/2011, 11:05 PM
Not very efficient cuz it's late and Im tired...

CMD:oskin(playerid,params[])
{
new oskin1,oskin2;
if(PlayerInfo[playerid][Member] == -255) return 0;
CheckMySQL();
format(str, sizeof(str), "SELECT Skin1 FROM orgs WHERE Orgid = '%d'",orgid);
mysql_query(str);
mysql_store_result();
oskin1 = mysql_fetch_int(str);

mysql_free_result();
format(str, sizeof(str), "SELECT Skin2 FROM orgs WHERE Orgid = '%d'",orgid);
mysql_query(str);
mysql_store_result();
oskin2 = mysql_fetch_int(str);
if(GetPlayerSkin(playerid) == oskin1)
{
SetPlayerSkin(playerid,oskin2);
}
else if(GetPlayerSkin(playerid) == oskin2)
{
SetPlayerSkin(playerid,oskin1);
}
}
mysql_free_result();
return 1;
}

Tanush123
01/01/2012, 07:46 AM
D:\Users\Tanush\Desktop\SA-MP SERVERS\SA-MP Server Stunt\gamemodes\server.pwn(4382) : error 035: argument type mismatch (argument 1)
D:\Users\Tanush\Desktop\SA-MP SERVERS\SA-MP Server Stunt\gamemodes\server.pwn(4387) : error 035: argument type mismatch (argument 1)
first error: oskin1 = mysql_fetch_int(str);
second error: oskin2 = mysql_fetch_int(str);

THE_KNOWN
01/01/2012, 07:51 AM
CMD:oskin(playerid,params[])
{
new oskin1,oskin2;
if(PlayerInfo[playerid][Member] == -255) return 0;
CheckMySQL();
format(str, sizeof(str), "SELECT Skin1 FROM orgs WHERE Orgid = %d",orgid);
mysql_query(str);
mysql_store_result();
oskin1 = mysql_fetch_int();
mysql_free_result();
format(str, sizeof(str), "SELECT Skin2 FROM orgs WHERE Orgid = %d",orgid);
mysql_query(str);
mysql_store_result();
oskin2 = mysql_fetch_int();
if(GetPlayerSkin(playerid) == oskin1)
{
SetPlayerSkin(playerid,oskin2);
}
else if(GetPlayerSkin(playerid) == oskin2 || GetPlayerSkin(playerid) != oskin1)
{
SetPlayerSkin(playerid,oskin1);
}
}
mysql_free_result();
return 1;
}

Tanush123
01/01/2012, 08:11 AM
thanks