SA-MP Forums Archive
Connected players - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Connected players (/showthread.php?tid=625621)



Connected players - Loinal - 04.01.2017

PHP код:
    new NumPlayersMsg[128];
    
    
mysql_query("SELECT ID FROM players");
    
mysql_store_result();
    
NumPlayers mysql_num_rows();
    
mysql_free_result();
    
format(Msgsizeof(Msg), "{00FF50}%s has registered at xMs {FF0000}[Total Registered Players: %i]",GetName(playerid), NumPlayers);
    
SendClientMessageToAll(playerid,Msg); 
Logs:
Код:
[11:04:43] [debug] Run time error 19: "File or function is not found"
[11:04:43] [debug]  mysql_store_result
[11:04:43] [debug]  mysql_num_rows
[11:04:43] [debug]  mysql_free_result
[11:04:43] [debug] Run time error 19: "File or function is not found"
[11:04:43] [debug]  mysql_store_result
[11:04:43] [debug]  mysql_num_rows
[11:04:43] [debug]  mysql_free_result
[11:04:43] Script[gamemodes/xms.amx]: Run time error 19: "File or function is not found"
[11:04:43] Number of vehicle models: 0



Re: Connected players - Donboo - 04.01.2017

Check the version of your MySQL.


Re: Connected players - Lordzy - 04.01.2017

Your code looks like it requires older version of BlueG's MySQL plugin but I wouldn't suggest you to use that. This code is as per the latest version:
pawn Код:
new
    num_Players,
    msg_String[128],
    Cache:result
;
    result = mysql_query(connectionHandle, "SELECT COUNT(*) FROM `players`");
    //Better to count the number of rows than the number of results.
    num_Players = cache_get_value_index_int(0, 0);
    cache_delete(result);
    //format stuffs.



Re: Connected players - Loinal - 04.01.2017

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
Your code looks like it requires older version of BlueG's MySQL plugin but I wouldn't suggest you to use that. This code is as per the latest version:
pawn Код:
new
    num_Players,
    msg_String[128],
    Cache:result
;
    result = mysql_query(connectionHandle, "SELECT COUNT(*) FROM `players`");
    //Better to count the number of rows than the number of results.
    num_Players = cache_get_value_index_int(0, 0);
    cache_delete(result);
    //format stuffs.
Код:
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2232) : error 017: undefined symbol "connectionHandle"
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2232) : warning 213: tag mismatch
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2234) : error 017: undefined symbol "cache_get_value_index_int"
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2237) : error 029: invalid expression, assumed zero
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2237 -- 2238) : error 029: invalid expression, assumed zero
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2238) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
4 Errors.


Re: Connected players - Yaa - 04.01.2017

Quote:
Originally Posted by Loinal
Посмотреть сообщение
Код:
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2232) : error 017: undefined symbol "connectionHandle"
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2232) : warning 213: tag mismatch
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2234) : error 017: undefined symbol "cache_get_value_index_int"
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2237) : error 029: invalid expression, assumed zero
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2237 -- 2238) : error 029: invalid expression, assumed zero
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2238) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
4 Errors.
use lastest version go in ****** and write ''MySQL Plugin BlueG Lastest" download it put in ur plugins blbablbblabla and recomplie ur gm


Re: Connected players - Loinal - 04.01.2017

Quote:
Originally Posted by Yaa
Посмотреть сообщение
use lastest version go in ****** and write ''MySQL Plugin BlueG Lastest" download it put in ur plugins blbablbblabla and recomplie ur gm
Код:
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2232) : error 017: undefined symbol "connectionHandle"
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2232) : warning 213: tag mismatch
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2234) : warning 202: number of arguments does not match definition
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2237) : error 029: invalid expression, assumed zero
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2237 -- 2238) : error 029: invalid expression, assumed zero
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2238) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: Connected players - Loinal - 04.01.2017

Fixed but

This
PHP код:
D:\samp folder\(XteMeSxMs\gamemodes\xMs.pwn(2232) : error 035argument type mismatch (argument 1)
D:\samp folder\(XteMeSxMs\gamemodes\xMs.pwn(2232) : warning 213tag mismatch
D
:\samp folder\(XteMeSxMs\gamemodes\xMs.pwn(2234) : warning 202number of arguments does not match definition
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase


1 Error

Lines:

Код:
    result = mysql_query(mysql, "SELECT COUNT(*) FROM `players`");

    num_Players = cache_get_value_index_int(0, 0);



Re: Connected players - Konstantinos - 04.01.2017

"mysql" variable should have MySQL: tag.

In R40+ the value is passed by reference:
pawn Код:
cache_get_value_int(0, 0, num_Players);
But.. what you can do is execute the query once when the server starts and assign to a global variable the number of registered users. Every time a new player registers, increase the variable and format your text.


Re: Connected players - Loinal - 04.01.2017

Last thing:

PHP код:
result mysql_query(mysql"SELECT COUNT(*) FROM `players`"); 
errors:

D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2230) : error 035: argument type mismatch (argument 1)
D:\samp folder\(XteMeS) xMs\gamemodes\xMs.pwn(2230) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.


Re: Connected players - BiosMarcel - 04.01.2017

"result" needs to have a Cache tag and "mysql" needs the MySQL tag. Did u even read want Konstantinos wrote