GeehFox
10-08-2014, 03:21
Hello there, I'm trying to make a new plug in to edit the admin.cfg file, in order to insert the specified player's name, flag, and such.
I thought I did everything correctly, and managed to fix some of the issues, but some still remain, and I think it would be nice to know what I've done wrong, exactly (First time from Assembly to Sourcemod-C-like thing :oops:)
#include <sourcemod>
public Plugin:myinfo =
{
name = "GiveOP",
author = "Geeh",
description = "Gives OP powers using /giveop",
version = "1.0",
url = "http://www.foxyfriends.eu/"
};
public OnPluginStart();
{
RegAdminCmd("sm_giveop", Command_GiveOP, ADMFLAG_SLAU);
}
public Action:Command_GiveOP(client, args)
{
new String:arg1[32], String:arg2[32];
new flag;
new MAX_NAME_LENGHT;
MAX_NAME_LENGHT = 256;
if (args >= 2 && GetCmdArg(2, arg2, sizeof(arg2)))
{
flag = arg2;
}
new target = FindTarget(client, arg1);
if (target == -1)
{
return Plugin_Handled;
}
//Get name
new String:name[MAX_NAME_LENGHT];
//Get Steam ID
new String:steamid[MAX_NAME_LENGHT];
GetClientAuthString(ProcessTargetString(name) , String:steamid, TRUE);
GetClientName(target, name, sizeof(name));
//Initialize File
decl String:path[PLATFORM_MAX_PATH][128];
//File stream
BuildPath(Path_SM,path,PLATFORM_MAX_PATH,"admin.cfg");
new Handle:fileHandle=OpenFile("addons/sourcemod/configs/admin.cfg", "a");
//Writing to file
WriteFileLine(fileHandle,"Plugin/n{/n"$name"/n{"auth" "$steamid"/n"identity" "$steamid"/n"flags" "$flag"/n}}";
CloseHandle(fileHandle);
return Plugin_Handled;
}
Errors:
giveop.sp<12> : error 010: invalid function or declaration
giveop.sp<26> : error 006: must be assigned to an array
giveop.sp<37> : error 092: number of arguments does not match definition
giveop.sp<38> : warning 224: indeterminate array size in "sizeof" expression <symbol "">
giveop.sp<42> : error 048: array <s do not match
giveop.sp<45> : error 001: expected token: ",", but found "$"
giveop.sp<45> : error 029: invalid expression, assumed zero
giveop.sp<45> : warning 214: expression has no effect
giveop.sp<45> : error 001: expected token: ";", but found "-string-"
giveop.sp<45> : fatal error 127: too many error messages on one line
I thought I did everything correctly, and managed to fix some of the issues, but some still remain, and I think it would be nice to know what I've done wrong, exactly (First time from Assembly to Sourcemod-C-like thing :oops:)
#include <sourcemod>
public Plugin:myinfo =
{
name = "GiveOP",
author = "Geeh",
description = "Gives OP powers using /giveop",
version = "1.0",
url = "http://www.foxyfriends.eu/"
};
public OnPluginStart();
{
RegAdminCmd("sm_giveop", Command_GiveOP, ADMFLAG_SLAU);
}
public Action:Command_GiveOP(client, args)
{
new String:arg1[32], String:arg2[32];
new flag;
new MAX_NAME_LENGHT;
MAX_NAME_LENGHT = 256;
if (args >= 2 && GetCmdArg(2, arg2, sizeof(arg2)))
{
flag = arg2;
}
new target = FindTarget(client, arg1);
if (target == -1)
{
return Plugin_Handled;
}
//Get name
new String:name[MAX_NAME_LENGHT];
//Get Steam ID
new String:steamid[MAX_NAME_LENGHT];
GetClientAuthString(ProcessTargetString(name) , String:steamid, TRUE);
GetClientName(target, name, sizeof(name));
//Initialize File
decl String:path[PLATFORM_MAX_PATH][128];
//File stream
BuildPath(Path_SM,path,PLATFORM_MAX_PATH,"admin.cfg");
new Handle:fileHandle=OpenFile("addons/sourcemod/configs/admin.cfg", "a");
//Writing to file
WriteFileLine(fileHandle,"Plugin/n{/n"$name"/n{"auth" "$steamid"/n"identity" "$steamid"/n"flags" "$flag"/n}}";
CloseHandle(fileHandle);
return Plugin_Handled;
}
Errors:
giveop.sp<12> : error 010: invalid function or declaration
giveop.sp<26> : error 006: must be assigned to an array
giveop.sp<37> : error 092: number of arguments does not match definition
giveop.sp<38> : warning 224: indeterminate array size in "sizeof" expression <symbol "">
giveop.sp<42> : error 048: array <s do not match
giveop.sp<45> : error 001: expected token: ",", but found "$"
giveop.sp<45> : error 029: invalid expression, assumed zero
giveop.sp<45> : warning 214: expression has no effect
giveop.sp<45> : error 001: expected token: ";", but found "-string-"
giveop.sp<45> : fatal error 127: too many error messages on one line