Raised This Month: $51 Target: $400
 12% 

Problems Passing Variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pythong
SourceMod Donor
Join Date: Dec 2008
Old 10-23-2012 , 16:00   Problems Passing Variable
Reply With Quote #1

What am i doing wrong here? I want it so when a player connects it will query a database to grab a value and then check if that value is larger than a preset cvar. If it is it i will build a "admin flag" used to give perks. eg if i have 1000pts and it does a greater than check, if it passes it will build a sql string to give me that flag which is defined as eorflag (end of round flag)


There are two bold sections im stuck on. The first is the building of the admin flag. The second is passing that admin flag over to GiveReward() to use in the sql query/update string.


Code:
public Action:Command_JoinTeam(client, const String:command[], argc) 
{
	new lp = GetLP(client);
	PrintToChat(client, "Points: %i.", lp);
	if (lp >= price_eor)
	{
		new String:setflags[256];
		Format(setflags, sizeof(setflags), "%s", eorflag);
		//PrintToChat = (client, "You have flag: %s", eorflag);
		GiveReward(client, setflags);
	}
	else if (lp >= price_ab)
		{
			/*new setflags = "";
			setflags = (%s%s, cv_eorflag, cv_abflag);
			PrintToChat = (client, "You have flag: %", eorflag, abflag);
			GiveReward(client, setflags);
			*/
		}
		else if (lp >= price_rs)
			{
				/*new setflags = "";
				setflags = (%s%s, cv_eorflag, cv_abflag, cv_rsflag);
				PrintToChat = (client, "You have flag: %", eorflag, abflag, rsflag);
				GiveReward(client, setflags);
			*/
			}
			else
			{
				PrintToChat(client, "\x01[\x07FF0000RP\x01] Points: \x07FFA500%i\x01. No benefits added.", lp);
			}	
}  

GetLP(client)
{
	new String:sqlstring[255];
	Format(sqlstring, sizeof(sqlstring), "SELECT points FROM rp WHERE id = %i", sql_id[client]);
	
	SQL_LockDatabase(dbcon);
	
	new Handle:sql = SQL_Query(dbcon, sqlstring);
	SQL_FetchRow(sql);
	new lp = SQL_FetchInt(sql, 0);
	CloseHandle(sql);
	
	SQL_UnlockDatabase(dbcon);
	
	return lp;
}

GiveLP(amount)
{
	new String:sqlstring[256];
	Format(sqlstring, sizeof(sqlstring), "UPDATE rp SET points = points + %i WHERE ingame = 1 AND ingameid = %i", amount, serverid);
	SQL_TQuery(dbcon, EmptyResultSet, sqlstring);
	//PrintToChat("\x01[\x07FF0000RP\x01] New Balance: +\x07FFA500%i\x01.", amount);
}

GiveReward(client, args)
{
	if (IsClientInGame(client))
	{
		// In die lp-Datenbank eintragen (Step 1)
		new String:steamid[50];
		GetClientAuthString(client, steamid, sizeof(steamid))
		new String:sqlstring[256];
		Format(sqlstring, sizeof(sqlstring), "UPDATE rp SET rs = 1, serverid = %i WHERE steamid = '%s'", serverid, steamid);
		SQL_TQuery(dbcon, EmptyResultSet, sqlstring);
		
		// In die sm-Admin Datenbank eintragen (Step 2)
		new String:sqlstring2[256];
		Format(sqlstring2, sizeof(sqlstring2), "INSERT INTO sm_admins(authtype, identity, flags, name, immunity) VALUES ('steam' ,'%s', '%s', '%N', %i)", steamid, rewardflag, client, rsimmunity);
		SQL_TQuery(dbcon, EmptyResultSet, sqlstring2);
		
		ServerCommand("sm_reloadadmins");
	}
}

Last edited by Pythong; 10-23-2012 at 16:01.
Pythong is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-23-2012 , 16:26   Re: Problems Passing Variable
Reply With Quote #2

PHP Code:
GiveReward(clientargs
Two things:
  1. Why is the second argument named args? This function isn't a ConCmd as far as I can tell.
  2. args needs to be declared as a String if you're passing a string into it, such as String:args[]
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-24-2012 , 03:10   Re: Problems Passing Variable
Reply With Quote #3

Why all the stuff is inside jointeam? What's up with your indentation? You shouldn't edit SQL admins, use admin API instead.
__________________
FaTony is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode