Raised This Month: $ Target: $400
 0% 

Deutsche Scripting-Hilfe


  
 
 
Thread Tools Display Modes
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 12-03-2008 , 05:54   Re: Deutsche Scripting-Hilfe
#101

äh, nö, ist das selbe ^^
[0][0] = "H", [0][4] ist "o", [0][5] = "\0", also von [0][0] bis [0][5] = "Hello/0"
[1][0] = "m", [1][2] ist "y", [1][3] = "\0", also von [1][0] bis [1][3] = "my/0"
[2][0] = "f", [2][5] ist "d", [2][6] = "\0", also von [2][0] bis [2][6] = "friend/0"
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who don´t.

Last edited by |PJ| Shorty; 12-03-2008 at 05:59.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 12-03-2008 , 10:10   Re: Deutsche Scripting-Hilfe
#102

array[2][6]

array[0] = "hello"
array[0][0] = 'h'
array[0][1] = 'e'
array[0][2] = 'l'
array[0][3] = 'l'
array[0][4] = 'o'
array[0][5] = '^0'

array[1] = "my"
array[1][0] = 'm'
array[1][1] = 'y'
array[1][2] = '^0'

array[2] = "friend"
array[2][0] = 'f'
array[2][1] = 'r'
array[2][2] = 'i'
array[2][3] = 'e'
array[2][4] = 'n'
array[2][5] = 'd'
array[2][6] = '^0'

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

'^0' beendet den string an der stelle, zb

array[2] = "friend"
array[2][0] = 'f'
array[2][1] = 'r'
array[2][2] = 'i'
array[2][3] = '^0'
array[2][4] = 'e'
array[2][5] = 'n'
array[2][6] = 'd'

währe array[2] beim printen nur noch "fri"
___________________________________

array[REIHE][SPALTE]

was shorty nu meint ist dass du erstma in der tabelle nach der reihe guckst und dann in der reihe die einzelnen spalten werte abgehst....
irgendwie nur logisch und wenn du shortys posts nochmal durchliest müsste es eigentlich klar werden :S

btw lerning by doing ist besser als stur die documentation zu lesen :S
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Schlesie
Senior Member
Join Date: May 2005
Location: Wiesbaden
Old 12-18-2008 , 07:37   Re: Deutsche Scripting-Hilfe
#103

Ich möchte gern das Frequent Fragger Program für meine Zwecke etwas umgestalten. Zunächst geht es darum das die Spielzeit die jeder auf unseren Servern verbringt in einer Datenbank gespeichert wird. Später sollen daran bestimmte Rechte geknüpft werden. So ein Art Stammspieler-Plugin
Bereits am speichern der Spielzeit scheitere ich aber. Hab das o.g. Plugin erstmal auf den folgenden Code geschrumpft. Nun wird aber keinerlei Datenbank angelegt. Lege ich sie von Hand an werden auch keine Daten eingetragen. Es kommt auch keinerlei Fehlermeldung, kein Connection Failed oder so sowas, nix.

Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>

new gConnectTime[33]
//new gCurrentTime
new gTotalKills[33]
new gTotalDeaths[33]


new Sql:dbc
new Result:result

public plugin_init()
{
	register_plugin("FrequentFraggerProgram","4.7","Slurpy [COF]")
	register_cvar("FreqFragProg", "4.7",FCVAR_SERVER)
	register_cvar("amx_ffphistory", "30") //how many days to keep when running amx_ffpprune
	register_cvar("amx_ffpdbmaintenance","05:00")
	register_cvar("amx_ffpdecay","5")
	set_task(60.0,"schedule_dbmaintenance",1,"",0,"b")

	new host[64], username[32], password[32], dbname[32], error[256]
	get_cvar_string("amx_sql_host",host,63)
	get_cvar_string("amx_sql_user",username,31)
	get_cvar_string("amx_sql_pass",password,31)
	get_cvar_string("amx_sql_db",dbname,31)
	dbc  =  dbi_connect(host,username,password,dbname,error,255)
	if (dbc  ==  SQL_FAILED)
	log_amx("[AMXX] SQL Connection Failed = %s", error)
	else
	{
		dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `freqfragger` (`lastname` VARCHAR(32) NOT NULL,`steamid` VARCHAR(32) NOT NULL,`connecttime` INT NOT NULL,`totalkills` INT NOT NULL,`totaldeaths` INT NOT NULL,`date` TIMESTAMP, PRIMARY KEY(`steamid`))")
	}
}



//////////////////////////////////////////////////////////////////////////////////////////
//      Update players stored time when they disconnect
//////////////////////////////////////////////////////////////////////////////////////////

public client_disconnect (id){  
	if ( is_user_bot(id) ) 
	{  //Do not add to database/nvault
	return PLUGIN_CONTINUE
	}
	if (is_user_hltv(id) ) 
	{  //Do not add to database/nvault
	return PLUGIN_CONTINUE
	}
	
	new authid[32]
	new playtime = get_user_time (id)
	get_user_authid(id,authid,31)
	
	new player_name[33]
	get_user_name(id,player_name,31)
	if (gConnectTime[id]== 0) {			
		//New player, create a database entry for them
		result = dbi_query(dbc,"INSERT INTO freqfragger (lastname, steamid, connecttime, totalkills, totaldeaths, date) values ('%s','%s',%i,%i,%i,NOW())",player_name,authid,playtime,gTotalKills[id],gTotalDeaths[id])
	}else{ 
			
		//Player exists in database, add the time to the total time
		new store_time = (playtime + gConnectTime[id])
		result = dbi_query(dbc,"UPDATE freqfragger SET lastname='%s', connecttime=%i, totalkills=%i, totaldeaths=%i, date=NOW() WHERE steamid='%s'",player_name,store_time, gTotalKills[id],gTotalDeaths[id],authid)
	}
	return PLUGIN_CONTINUE
}

//////////////////////////////////////////////////////////////////////////////////////////
//      Remove old entries for players not on server in X days for MySql
//////////////////////////////////////////////////////////////////////////////////////////

public schedule_dbmaintenance()  //Clean up database
 {
	new thetimeis[16],dbdecay_time[16]
	get_time("%H:%M",thetimeis,16)
	get_cvar_string("amx_ffpdbmaintenance",dbdecay_time,16)
	
	if(equal(thetimeis,dbdecay_time)){ //It's time to do the maintenance
		new history = get_cvar_num("amx_ffphistory") //Delete player from database after certain number of days not on server
		
		result = dbi_query(dbc,"DELETE FROM  freqfragger WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date ) >=%d",history )
		result = dbi_query(dbc,"DELETE FROM  freqfragger WHERE steamid = 'STEAM_ID_PENDING'")
		
		new slotdecay = get_cvar_num("amx_ffpdecay")
		new decaypct = (100 - slotdecay)
		
		//Remove percentage of players total time if not on server in the last day
		result = dbi_query(dbc,"UPDATE freqfragger SET lastname=lastname, steamid=steamid, connecttime=connecttime*.%i, totalkills=totalkills, totaldeaths=totaldeaths, date=date WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date ) >=1 ",decaypct)
		
		dbi_free_result(result)
	}
	return PLUGIN_CONTINUE
 }
Ich muss zugeben ich hab nicht gerade viel Ahnung vom coden. Bis auf ein paar kleinere Anpassung oder Übersetzungen hab ich noch nichts gemacht. Ich schau mir meist einfach die sma-dateien an und versuch draus schlau zu werden. Der Rest ist dann nach dem Prinzip "Versuch und Irrtum".
Aber vielleicht kann mir trotzdem jemand einen Tipp geben. Danke
__________________
Schlesie is offline
Send a message via ICQ to Schlesie
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 12-18-2008 , 11:09   Re: Deutsche Scripting-Hilfe
#104

dbi war vor meiner zeit, hier mal ein beispiel mit sqlx.
es fehlt eigentlich nur das "db prune", alles andere sollte funktionieren.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
new Handle:dbc;
new 
g_Cache[1024];
new 
g_authid[33][35]
public 
plugin_init() {
 
register_plugin("FrequentFraggerProgram","4.7","Slurpy [COF]")
 
register_cvar("FreqFragProg""4.7",FCVAR_SERVER)
}
public 
plugin_cfg() {
 
set_task(1.0,"sql_init")
}
public 
sql_init() {
 new 
host[64], username[32], password[32], dbname[32];
 
//no pcvar, only called once at plugin start
 
get_cvar_string("amx_sql_host",host,64);
 
get_cvar_string("amx_sql_user",username,32);
 
get_cvar_string("amx_sql_pass",password,32);
 
get_cvar_string("amx_sql_db",dbname,32);
 
 
SQL_SetAffinity("mysql");
 
dbc SQL_MakeDbTuple(host,username,password,dbname);
 
 
formatex(g_Cache,1023,"CREATE TABLE IF NOT EXISTS `freqfragger` (\
  `lastname` VARCHAR(32) NOT NULL,`steamid` VARCHAR(35) NOT NULL,\
  `connecttime` INT NOT NULL,`totalkills` INT NOT NULL,\
  `totaldeaths` INT NOT NULL,`date` TIMESTAMP NOT NULL, PRIMARY KEY(`steamid`))"
)
 
SQL_ThreadQuery(dbc,"TableHandle",g_Cache); 
}
public 
client_authorized(id) {
 
get_user_authid(id,g_authid[id],charsmax(g_authid[]))
}
public 
client_disconnect(id){  
 if ( 
is_user_bot(id) || is_user_hltv(id) ) 
  return 
PLUGIN_CONTINUE
 
 
new playtime get_user_time (id,1); //1=without connection time
 
 
new player_name[32]
 
get_user_name(id,player_name,31)
 
 new 
deaths=get_user_deaths(id)
 new 
kills=get_user_frags(id)
 
 
formatex(g_Cache,1023,"INSERT INTO freqfragger \
  (lastname, steamid, connecttime, totalkills, totaldeaths, date) \
  values ('%s','%s',%i,%i,%i,NOW()) ON DUPLICATE KEY UPDATE \
  lastname='%s', connecttime=connecttime+%i, totalkills=totalkills+%i, \
  totaldeaths=totaldeaths+%i, date=NOW()"
, \
  
player_name,g_authid[id],playtime,kills,deaths, \
  
player_name,playtime,kills,deaths)
 
 
SQL_ThreadQuery(dbc,"TableHandle",g_Cache);
 return 
PLUGIN_CONTINUE
}
public 
TableHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize,Float:QueryTime)
{
 
// lots of error checking
 
if(FailState == TQUERY_CONNECT_FAILED)
  return 
log_amx("Could not connect to SQL database.");
 else if(
FailState == TQUERY_QUERY_FAILED)
  return 
log_amx("SQL Table Query failed.");
 if(
Errcode)
  return 
log_amx("SQL Error on table query: %s",Error);
 
 return 
PLUGIN_CONTINUE;
}
public 
plugin_end() {
 
SQL_FreeHandle(dbc)

__________________
There are only 10 types of people in the world:
Those who understand binary, and those who don´t.

Last edited by |PJ| Shorty; 01-21-2009 at 15:48. Reason: Query updated
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
Schlesie
Senior Member
Join Date: May 2005
Location: Wiesbaden
Old 12-18-2008 , 14:04   Re: Deutsche Scripting-Hilfe
#105

Danke dir, werds demnächst mal testen und mir sqlx doch etwas genauer ansehen.
__________________
Schlesie is offline
Send a message via ICQ to Schlesie
ab²
Member
Join Date: Dec 2008
Old 12-28-2008 , 17:46   Re: Deutsche Scripting-Hilfe
#106

hey

ich wollte mal ein plugin schreiben, welches das awp-zoom gegen das aug zoom austauscht, aber ich komm nich weiter

irgendwie müsste ich ja das public (id) abrufen können aber ich weiß nich wie

Code:
#include <amxmodx>
#include <cstrike>

#define PLUGIN "AWP Smooth Zoom"
#define VERSION "0.1"
#define AUTHOR "ab2"

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
}


public (id)
{
        if(is_user_connected(id) && is_user_alive(id))
    {
            if (get_user_weapon(id) == CSW_AWP) 
            
            {
                cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1);
                return 0;
        }
    }
}

weiß da jemand rat?

ab²
ab² is offline
ch3cker
Veteran Member
Join Date: Jun 2005
Location: Deutschland / Baden-Würt
Old 12-28-2008 , 18:36   Re: Deutsche Scripting-Hilfe
#107

vllt. hilft dir des:
http://forums.alliedmods.net/showthr...ight=user+zoom
__________________
SORRY 4 MY BAD ENGLISH
ch3cker is offline
ab²
Member
Join Date: Dec 2008
Old 12-29-2008 , 10:55   Re: Deutsche Scripting-Hilfe
#108

danke für den link


wenn ich jetzt mit awp zoome, dann zoomt es im style der aug/sg552, nach nochmaligen drücken gehts aus dem zoom raus

was jetzt noch umgeschrieben werden sollte, dass der schwarze rand beim zoomen wegbleibt, auch wie bei aug/sg552

ist sowas realisierbar?


ich dachte auch, wenn ich jetzt in die console awp_smoothzoom "0" rein schreibe, dass das deaktiviert wird, wirds aber nicht... hab ich da was vergessen?


wenn ich jetzt mit der awp im zoom schiese und nachgeladen wurde, geht es wieder in den zoom mit dem großen (normalen) awp zoom in der mitte, aber der schwarze rand ist dann weg...


PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "AWP Smooth Zoom"
#define VERSION "0.1"
#define AUTHOR "ab2"



public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("CurWeapon","awp_smoothzoom","be","1=1","2=18")
    
register_cvar("awp_smoothzoom""1")
}
   
public 
awp_smoothzoom(id)
{
    if(
is_user_alive(id) == 0)
        return 
PLUGIN_HANDLED
        
        
if(cs_get_user_zoom(id) == CS_SET_FIRST_ZOOM)
        
cs_set_user_zoom (id,CS_SET_AUGSG552_ZOOM,1)
        
        else(
cs_get_user_zoom(id) == CS_SET_NO_ZOOM)
        return 
PLUGIN_HANDLED 


Last edited by ab²; 12-29-2008 at 11:25.
ab² is offline
ab²
Member
Join Date: Dec 2008
Old 12-31-2008 , 06:44   Re: Deutsche Scripting-Hilfe
#109

so siehts aus, wenn ich das jetzt benutze
http://flickcabin.com/public/view/17067


code ist jetzt in pcvar (hoffentlich ^^) geschrieben worden - nich von mir

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
 
#define PLUGIN "AWP Smooth Zoom"
#define VERSION "0.1"
#define AUTHOR "ab2"
new awp;
public 
plugin_init() 
{
register_plugin(PLUGINVERSIONAUTHOR)
awp register_cvar("awp_change""1")
register_event("CurWeapon","function","be","1=1","2=18")
}
 
public function(
id)
{
      if(!
is_user_alive(id))
           return 
PLUGIN_HANDLED
   
if(get_pcvar_num(awp))
   {
          new 
value cs_get_user_zoom(id);
          if(
value == || value == 3)cs_set_user_zoom (id41);
   }
  return 
PLUGIN_HANDLED

__________________
+ Karma if helped! Thanks!
ab² is offline
bmp
Senior Member
Join Date: Nov 2007
Location: Berlin, Germany
Old 01-11-2009 , 06:59   Re: Deutsche Scripting-Hilfe
#110

hi,
ich versuche gerade die geschwindigkeit mit client_cmd(id, "cl_forwardspeed 500") und set_user_maxspeed(id,500.0) zu erhöhen. sobald aber die waffe gewechselt wird, ist wieder alles beim alten. wird die geschwindigkeit dagegen auff z.b. 200 gesenkt, funktioniert das wie gewünscht.


*verwirrt*

Last edited by bmp; 01-11-2009 at 08:53.
bmp 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 16:56.


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