Raised This Month: $ Target: $400
 0% 

Problems Passing Variable


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 11:43.


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