Promote command. -
xX4m4zingXx - 18.01.2015
I want to create a promote command.
I was looking at a kick command and tried to create a promote command from it.
this is my code:
Код:
#include <a_samp>
#include <zcmd>
public OnPlayerCommandText(playerid, cmdtext[])
{
CMD:giverights(playerid, pRights)
{
if(PlayerInfo[playerid][pRights] == 3)
{
new target;
new rights[64];
new str[128];
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(target, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", target,rights)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]");
if(!IsPlayerConnected(target))
return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
PlayerInfo[target][pRights] = rights;
}
}
}
Error:
Код:
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(6) : error 029: invalid expression, assumed zero
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(6) : error 017: undefined symbol "cmd_giverights"
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(6) : error 029: invalid expression, assumed zero
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(6) : fatal error 107: too many error messages on one line
Re: Promote command. -
CalvinC - 18.01.2015
pawn Код:
#include <a_samp>
#include <zcmd>
CMD:giverights(playerid, params[])
{
if(PlayerInfo[playerid][pRights] < 3) return 0;
new target, rights[64], str[128], Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(target, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", target,rights)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
PlayerInfo[target][pRights] = rights;
return 1;
}
ZCMD commands shouldn't be placed under OnPlayerCommandText.
Also fixed some other errors for you as you can examine.
Re: Promote command. -
xX4m4zingXx - 18.01.2015
It says that PlayerInfo isn't defined.
can I take things from other filterscripts?
I got a login script where I want to take PlayerInfo from.
Or do I have to recreate that small part?
This is the login script:
Код:
#include <a_samp>
#include <YSI\y_ini>
//Dialogs
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
//Users path
#define PATH "/users/%s.ini"
//Colors
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{485CFF}"
#define COL_YELLOW "{F7C600}"
enum pInfo
{
pPass,
pCash,
pRights,
pKills,
pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++)
{
if(string[i] == find)
{
string[i] = replace;
}
}
}
stock GetName(playerid)
{
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
strreplace(name, '_', ' ');
return name;
}
main()
{
print("Login by Ruud");
}
public OnFilterScriptInit()
{
SetGameModeText("Login script");
return 1;
}
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Rights",PlayerInfo[playerid][pRights]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
new string[128], playerName[24];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, 128, COL_YELLOW"Welcome back "COL_LIGHTBLUE"%s "COL_WHITE"\nplease type your password below to log in.", GetName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Login", string, "Login", "Quit");
}
else
{
new string[128], playerName[24];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, 128, COL_YELLOW"Welcome "COL_LIGHTBLUE"%s "COL_WHITE"\n Type your password below to register a new account.", GetName(playerid));
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, COL_WHITE"Registering...", string, "Register", "Quit");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Rights",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Rights",PlayerInfo[playerid][pRights]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}
Re: Promote command. -
CalvinC - 18.01.2015
You cannot use information from filterscripts/gamemodes in other filterscripts/gamemodes.
Re: Promote command. -
xX4m4zingXx - 18.01.2015
Okay, thank you.
Re: Promote command. -
xX4m4zingXx - 18.01.2015
I got this script now:
Код:
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>
#include <sscanf2>
#define PATH "/users/%s.ini"
enum pInfo
{
pRights
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Rights",PlayerInfo[playerid][pRights]);
return 1;
}
CMD:giverights(playerid, rights)
{
if(PlayerInfo[playerid][pRights] < 3) return 0;
new target, rights[64], Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(target, Playername, sizeof(Playername));
if(sscanf(pRights, "us[64]", target,rights)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /kick [playerid] [reason]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, 0xFFFFFFAA, "Player is not connected!");
PlayerInfo[target][pRights] = rights;
return 1;
}
I got this error:
Код:
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(25) : warning 217: loose indentation
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(25) : warning 219: local variable "rights" shadows a variable at a preceding level
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(28) : error 035: argument type mismatch (argument 1)
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(30) : error 006: must be assigned to an array
Re: Promote command. -
nezo2001 - 18.01.2015
PHP код:
if(sscanf(params, "us[64]", target,rights)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /kick [playerid] [reason]");
Re: Promote command. -
xX4m4zingXx - 18.01.2015
Now I get this error:
Код:
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(33) : warning 217: loose indentation
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(33) : warning 219: local variable "rights" shadows a variable at a preceding level
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(36) : error 017: undefined symbol "params"
C:\Users\Ruud\Documents\Samp\filterscripts\admin.pwn(38) : error 006: must be assigned to an array
Re: Promote command. -
nezo2001 - 18.01.2015
PHP код:
CMD:giverights(playerid, params[])
Re: Promote command. -
xX4m4zingXx - 23.01.2015
Okay, I have this code now:
Код:
CMD:giverights(playerid, params[])
{
if(PlayerInfo[playerid][pRights] < 3) return 0;
new target, rights[64], Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(target, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", target,rights)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /kick [playerid] [reason]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COL_GREY, "Player is not connected!");
PlayerInfo[target][pRights] = rights;
return 1;
}
And I have this error:
Код:
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(582) : error 006: must be assigned to an array