#include <a_samp> //you proberbly know what this is.
#include <sscanf2> // this is the sscanf include you also need to add something in your server.cfg, coming later in the tut.
#include <YSI\y_ini> // this is our saving system you proberbly downloaded the hole YSI libary so the includes is inside the YSI folder
#include <zcmd> // this is our commands prossesor if you want to use y_commands replace #include <zcmd> with #include <YSI\y_commands>
echo Executing Server Config... lanmode 0 rcon_password changeme maxplayers 35 port 7777 hostname hostname gamemode0 gamemod filterscripts filterscipts plugins sscanf //<===== this is the line we need to add announce 0 query 1 weburl www.sa-mp.com onfoot_rate 40 incar_rate 40 weapon_rate 40 stream_distance 300.0 stream_rate 1000 maxnpc 0 logtimeformat [%H:%M:%S]
CMD:promote(playerid,params[])
{
new id,level;
if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON
{
if(sscanf(params,"ud",id,level) return //add the sendclientmessage usage: /promote name/id level or something "u" checks the if the player wrote a id or name "d" checks what level you wrote
else
{
if(level > 5) return //if the player writes a level thats over 5 he will get a error, write the error here
else
{
new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself
INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin.
INI_Close(File); //closes the ini file
}
}
}
else
{
//send a message that the player is not logged in as RCON
}
}
CMD:kick(playerid,params[])
{
new id,reason[128],name[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pAdmin] > 1) //this is also taken from the tut by Kush
{
if(sscanf(params,"us[128]",id,reason); return //your error message
else
{
format(string1,sizeof(string1),"%s have been kicked from the server: reason: %s",GetPlayerName(id,name,sizeof(name)),reason); //this will format the kick message that is being sent to all player connected
SendClientMessageToAll(0xFFFFFF,string1);
Kick(id);//kicks the player
}
}
else
{
//your error message about that the player is not a admin
}
}
CMD:ban(playerid,params[])
{
new id,reason[128],name[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pAdmin] > 1) //this is also taken from the tut by Kush
{
if(sscanf(params,"us[128]",id,reason); return //your error message
else
{
if(IsPlayerConnected(id))
{
format(string1,sizeof(string1),"%s have been banned from the server: reason: %s",GetPlayerName(id,name,sizeof(name)),reason); //this will format the kick message that is being sent to all player connected
SendClientMessageToAll(0xFFFFFF,string1);
Ban(id);//bans the player
}
else
{
new INI:File = INI_Open(UserPath(id));//this will just ban the name not the ip.
INI_WriteString(File,"Banned",1);//this is not written in the tut by Kush so we need to make it ourselves
INI_Close(File);
}//we will also add something OnPlayerConnect to make him really banned
}
}
else
{
//your error message about that the player is not a admin
}
}
public OnPlayerConnect(playerid)
{//you will need to put the fexist to check if the player have registered before this
new INI:File = INI_Open(UserPath(playerid));//and put the shit below when the dialog shows instead checking a something that does not exist
if(PlayerInfo[playerid][pBanned] == 1) return Ban(playerid); //now he's REALLY banned!
else
{
//show your login dialog
}
return 1;
}
pawn Код:
|
public OnPlayerConnect(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
if(fexist(UserPath(playerid))
{
//show login dialog and make a ban if he's banned
if(PlayerInfo[playerid][pBanned] == 1) return Ban(playerid); //now he's REALLY banned!
else
{
//show your login dialog
}
}
else return //register dialog
return 1;
}
Can someone help me? I used this tutorial to get the promote command and I got these errors:
(199) error 029: invalid expression, assumed zero (202) error 029: invalid expression, assumed zero Both 199 and 202 are: else and also a warning: warning 209: function "cmd_promote" should return a value |
CMD:promote(playerid,params[]) { new id,level; if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON { if(sscanf(params,"ud",id,level))return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Koristi: /promote [ID] [LVL]"); else { if(level > 5) return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Ne smijete ici iznad 5!"); else { new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin. INI_Close(File); //closes the ini file } } } }
CMD:promote(playerid,params[])
{
new id,level;
if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON
{
if(sscanf(params,"ud",id,level))return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Koristi: /promote [ID] [LVL]");
if(level > 5) return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Ne smijete ici iznad 5!");
new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself
INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin.
INI_Close(File); //closes the ini file
}
return 1;
}
CMD:promote(playerid,params[]) { new id,level; if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON { if(sscanf(params,"ud",id,level) return //add the sendclientmessage usage: /promote name/id level or something "u" checks the if the player wrote a id or name "d" checks what level you wrote else { if(level > 5) return //if the player writes a level thats over 5 he will get a error, write the error here else { new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin. INI_Close(File); //closes the ini file } } } else { //send a message that the player is not logged in as RCON } }
CMD:promote(playerid,params[]) { new id,level; if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON { if(sscanf(params,"ud",id,level) return //add the sendclientmessage usage: /promote name/id level or something "u" checks the if the player wrote a id or name "d" checks what level you wrote else { if(level > 5) return //if the player writes a level thats over 5 he will get a error, write the error here else { PlayerInfo[id][pAdmin] = level; } } } else { //send a message that the player is not logged in as RCON } }