26.06.2015, 10:47
I had the aka system with y_ini but now i need to do it with mysql.
I tried this code it's half as i couldn't really think what to do next with the script.
I want is that it should check all rows of mysql in aka database for the playername and ip, if name exists it should check it with the ip of player. IF both exists it should goto next step where it should be checking if playername and ip are in same column like this
[ip] [name]
127.0.0.1 | Sasuke_Uchiha
127.0.0.1 | AroseKhanNiazi
81.111.111.222 | Random_user
81.122.222.222 | Sasuke_Uchiha
this is what i am trying to create, and more over how would i be able to get all the names that are stored for a specific id example i want
/aka ip 127.0.0.1
this will show me name
"Sasuke_Uchiha"
"AroseKhanNiazi"
if i do
/aka name Sasuke_Uchiha
should show me
127.0.0.1
81.122.222.222
I am trying from few days but can't figure it out
with my current code i get these errors
and this is my database code
pawn Код:
stock LoadPlayerAka(playerid)
{
new mysqlquery[124];
mysql_format(g_SQL, mysqlquery, sizeof(mysqlquery), "SELECT ip,username FROM aka LIMIT 1");
print(mysqlquery);
mysql_pquery(g_SQL, mysqlquery,"OnAkaLoad", "d", playerid);
}
forward OnAkaLoad(playerid);
public OnAkaLoad(playerid)
{
new mysqlquery[124],name[MAX_PLAYER_NAME],bool:namefounded=false;
for(new i, j = cache_get_row_count(g_SQL); i < j; i++) // loop through all the rows that were found
{
cache_get_field_content(i, "username", name, g_SQL, MAX_PLAYER_NAME);
printf("Got row %d with name %s",i,name);
if(strcmp(name,PlayerInfo[playerid][pUserName]) == 0)
{
printf("Name Matched in row %d with name %s",i,name);
namefounded=true;
break;
}
}
if(namefounded=false)
{
mysql_format(g_SQL, mysqlquery, sizeof(mysqlquery), "INSERT INTO aka SET ip='%e',username='%e';",PlayerInfo[playerid][pIP],PlayerInfo[playerid][pUserName]);
print(mysqlquery);
}
return 1;
}
I want is that it should check all rows of mysql in aka database for the playername and ip, if name exists it should check it with the ip of player. IF both exists it should goto next step where it should be checking if playername and ip are in same column like this
[ip] [name]
127.0.0.1 | Sasuke_Uchiha
127.0.0.1 | AroseKhanNiazi
81.111.111.222 | Random_user
81.122.222.222 | Sasuke_Uchiha
this is what i am trying to create, and more over how would i be able to get all the names that are stored for a specific id example i want
/aka ip 127.0.0.1
this will show me name
"Sasuke_Uchiha"
"AroseKhanNiazi"
if i do
/aka name Sasuke_Uchiha
should show me
127.0.0.1
81.122.222.222
I am trying from few days but can't figure it out
with my current code i get these errors
Код:
Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0); Log("15:29:02","cache_get_field_content_int",2,"no active cache",0);
PHP код:
-- phpMyAdmin SQL Dump
-- version 4.3.11
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 26, 2015 at 12:46 PM
-- Server version: 5.6.24
-- PHP Version: 5.6.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `database`
--
-- --------------------------------------------------------
--
-- Table structure for table `aka`
--
CREATE TABLE IF NOT EXISTS `aka` (
`ip` varchar(16) NOT NULL,
`username` varchar(24) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;