i am trying to set clanstats system but when ever i try its works but its does not kick player which is not in clan and no error also tried with SLC plugin but no error
function onPlayerJoin( player )
{
Msg <- MessagePlayer;
Clan <- GetTag( player.Name );
Msg( "Hey Welcome " + player + " to the clanstats script!", player );
if ( Clan && IsClanRegister( Clan.tolower() ) ) Msg( "Note: You clan \"" + Clan + "\" is in server :D!", player );
else if ( Clan && !IsClanRegister( Clan.tolower() ) ) Msg( "Note: You have clan '" + Clan + "' you can add using, !regclan", player );
else if ( Clan && IsClanRegister( Clan.tolower() ) ) Msg( "Note: You clan \"" + Clan + "\" is in server :D!", player ), FindPlayerClan( player, player.Name );
else Msg( "Oh no you no have clan :(!", player );
}
function FindPlayerClan( player, string )
{
string = string;
local q = QuerySQL( sDB, "SELECT * FROM ClanUsers WHERE Clans='" + GetTag( string ) + "' COLLATE NOCASE" );
if (q == null)
{
local d = GetSQLColumnData( q, 1 ).tostring();
if( d == null )
{
TCC <- TruncateClan;
if ( d.tolower().find( TCC( string.tolower() ) ) ) { MessagePlayer( "Your Nick " + TCC( string ) + ", Clan: " + GetTag( string ), player ); } else { ClanKick( player ); return null; }
}
}
}
Note: Dont reply here if you dont know scripting specially people like finch who only know how to abuse please dont spam topic with useless replies
This is original script but i modified all things to 0.4 but having problem in above functions
http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=2070.0
* Firstly I do not understand your coding or how some of it really works. But I figured I would switch it up.
- This code is intended to help you find the error. Not a fix me.
Try this code and tell me what the error is
function onPlayerJoin( player )
{
Msg <- MessagePlayer;
Clan <- GetTag( player.Name );
Msg( "Hey Welcome " + player + " to the clanstats script!", player );
// else is not needed as we are only looking for one or the other
if ( Clan || !IsClanRegister( Clan.tolower() ) )
{
Msg( "Note: You have clan '" + Clan + "' you can add using, !regclan", player );
return;
}
// The other
if ( Clan || IsClanRegister( Clan.tolower() ) )
{
Msg( "Note: You clan \"" + Clan + "\" is in server :D!", player ),
FindPlayerClan( player, player.Name );
return;
}
else Msg( "Oh no, you have no clan :(!", player );
}
function FindPlayerClan( player, string )
{
string = string; // FindPlayerClan( player, player.Name ); Why is there two calls for the player?
local q = QuerySQL( sDB, "SELECT * FROM ClanUsers WHERE Clans='" + GetTag( string ) + "' COLLATE NOCASE" );
if (q != null)
{
local d = GetSQLColumnData( q, 1 ).tostring();
if( d != null )
{
TCC <- TruncateClan;
if ( d.tolower().find( TCC( string.tolower() ) ) )
{
MessagePlayer( "Your Nick " + TCC( string ) + ", Clan: " + GetTag( string ), player );
}
else ClanKick( player );
}
}
}
@
Quote from: Mötley on Oct 17, 2016, 12:04 PM* Firstly I do not understand your coding or how some of it really works. But I figured I would switch it up.
- This code is intended to help you find the error. Not a fix me.
Try this code and tell me what the error is
function onPlayerJoin( player )
{
Msg <- MessagePlayer;
Clan <- GetTag( player.Name );
Msg( "Hey Welcome " + player + " to the clanstats script!", player );
// else is not needed as we are only looking for one or the other
if ( Clan || !IsClanRegister( Clan.tolower() ) )
{
Msg( "Note: You have clan '" + Clan + "' you can add using, !regclan", player );
return;
}
// The other
if ( Clan || IsClanRegister( Clan.tolower() ) )
{
Msg( "Note: You clan \"" + Clan + "\" is in server :D!", player ),
FindPlayerClan( player, player.Name );
return;
}
else Msg( "Oh no, you have no clan :(!", player );
}
function FindPlayerClan( player, string )
{
string = string; // FindPlayerClan( player, player.Name ); Why is there two calls for the player?
local q = QuerySQL( sDB, "SELECT * FROM ClanUsers WHERE Clans='" + GetTag( string ) + "' COLLATE NOCASE" );
if (q != null)
{
local d = GetSQLColumnData( q, 1 ).tostring();
if( d != null )
{
TCC <- TruncateClan;
if ( d.tolower().find( TCC( string.tolower() ) ) )
{
MessagePlayer( "Your Nick " + TCC( string ) + ", Clan: " + GetTag( string ), player );
}
else ClanKick( player );
}
}
}
:P @Motley Thanks You said its not a fix but its working fine and its crashing server i think timer cant pass instance i will try to fix if cant i will tell you.
first its was working now error giving tostring does not exists in this line
local d = GetSQLColumnData( q, 1 ).tostring();
Try:-
null.tostring();
"abc".tostring();
Both of 'em won't work. First, you are trying to convert a null to string, secondly, you were trying to convert a string to a string. Add some condition checks.
Quote from: KAKAN on Oct 17, 2016, 01:45 PMTry:-
null.tostring();
"abc".tostring();
Both of 'em won't work. First, you are trying to convert a null to string, secondly, you were trying to convert a string to a string. Add some condition checks.
Plus the first error will make the second one automatically fail by making it unreachable.
I swear I stopped reading after this:
function onPlayerJoin( player )
{
Msg <- MessagePlayer;
Me too, dunno why he's creating global variables all the time...
I don't believe someone is too lazy to do MessagePlayer that he/she needs to create a variable like Msg :p