Jump to content

Register/login/admin systeem


Recommended Posts

Geplaatst: (bewerkt)

Hee mensen,,

Ik heb op de sa-mp forums een tutorial gezien voor het maken van je eigen register/login/admin systeem met dini...

nu kom ik op 1 line met 4 errors en 1 warning, alleen ik heb geen idee hoe ik deze weg krijg.

Aangezien ze op de sa-mp forums geen reactie geven na 1,5 dag hoop ik dat een van jullie hier raad me weet :puh:

Line 76 staat onder OnPlayerConnect callback, en staat ook aangegeven in die line.

Dit is de top van het script(waar het fout gaat):

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define GREY 0xAFAFAFAA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA

#if defined FILTERSCRIPT

enum gPInfo
{
Logged,
Regged,
Level
};
new PInfo[MAX_PLAYERS][gPInfo];
new file[256],n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}

public OnPlayerConnect(playerid)
{
LINE 76 ->>>    PInfo[playerid][Logged] = 0;
	PInfo[playerid][Regged] = 0;
	PInfo[playerid][Level] = 0;
new n[MAX_PLAYER_NAME], file[256];
	GetPlayerName(playerid,n,sizeof(n));
	format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
	if(dini_Exists(file))
	    {
			SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
			PInfo[playerid][Regged] = 1;
			PInfo[playerid][Logged] = 0;
			return 1;
		}
       if(!dini_Exists(file))
		{
			SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
			PInfo[playerid][Regged] = 0;
			PInfo[playerid][Logged] = 0;
			return 1;
		}
return 1;
}

En dit zijn de errors:

C:\Users\fts\Desktop\SA-MP-03ccc\filterscripts\aaddmmiinn.pwn(76) : error 017: undefined symbol "PInfo"

C:\Users\fts\Desktop\SA-MP-03ccc\filterscripts\aaddmmiinn.pwn(76) : warning 215: expression has no effect

C:\Users\fts\Desktop\SA-MP-03ccc\filterscripts\aaddmmiinn.pwn(76) : error 001: expected token: ";", but found "]"

C:\Users\fts\Desktop\SA-MP-03ccc\filterscripts\aaddmmiinn.pwn(76) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\filterscripts\aaddmmiinn.pwn(76) : fatal error 107: too many error messages on one line

Bewerkt: door minkema
Geplaatst:

Maak je een filterscript of een gamemode?

Als je een filterscript maakt moet je bovenaan simpelweg //#define FILTERSCRIPT uncommenten. Als je een gamemode maakt kan je het beste #if, #else, #endif, OnFilterScriptInit en OnFilterScriptExit uit je script verwijderen.

En dan nog een kleine notitie van mezelf: Ik raad je aan om geen oude methodes aan te leren (dini is zowat DE oudste file saving methode) en gebruik te maken van de nieuwste snufjes, zoals ZCMD voor commando's en Y_Ini voor file saving. Voor beide kan je wel tutorials vinden op het sa-mp forum.

Geplaatst: (bewerkt)

Maak je een filterscript of een gamemode?

Als je een filterscript maakt moet je bovenaan simpelweg //#define FILTERSCRIPT uncommenten. Als je een gamemode maakt kan je het beste #if, #else, #endif, OnFilterScriptInit en OnFilterScriptExit uit je script verwijderen.

En dan nog een kleine notitie van mezelf: Ik raad je aan om geen oude methodes aan te leren (dini is zowat DE oudste file saving methode) en gebruik te maken van de nieuwste snufjes, zoals ZCMD voor commando's en Y_Ini voor file saving. Voor beide kan je wel tutorials vinden op het sa-mp forum.

hmm, ja ik snap dat je dini niet echt een goed idee vind, maar voor nu vind ik het wel lekker om te snappen hoe dini werkt.

Wanneer ik #if defined filterscript, en alles wat daar onderzit wat met filterscript te maken heeft verwijder, krijg ik gigantisch veel errors, en ik denk eerlijkgezegd niet dat dat het probleem van die 4 errors zal oplossen. :puh:

btw, ik wil het gaan gebruiken als gamemode, ik heb hem nu ook al in de gamemode map geplaatst. Er stond inderdaad bij de topic nog in de filterscripts map.

Bewerkt: door minkema
Geplaatst:

Het zit 'm wel degelijk in die preprocessor directives (#if, etc). Jij hebt namelijk je variabelen gezet onder #if defined FILTERSCRIPT, wat betekend dat deze alleen door de compiler zullen gelezen worden als er ook #define FILTERSCRIPT in je script staat. Als je al je variabelen boven die regel zet is het probleem ook opgelost.

Geplaatst:

Maar als ik het als volgt doe, krijg ik een gigantische berg errors:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define GREY 0xAFAFAFAA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA

enum gPInfo
{
Logged,
Regged,
Level
};
new PInfo[MAX_PLAYERS][gPInfo];
new file[256],n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}

Geplaatst:

Ja, maar het is best om alles stap per stap op te lossen. Dit bijvoorbeeld kan helemaal niet en zal dan ook een boel errors genereren in de aard van 'Undefined symbol: playerid'.

       GetPlayerName(playerid,n,MAX_PLAYER_NAME);
       format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);

Dat zijn functies en die moeten altijd in een callback staan. In dit geval waarschijnlijk OnPlayerConnect. Het helpt ook als je de overige errors hier neer zet.

Geplaatst:

Klopt, daar zat een foutje dat inderdaad onder OnPlayerConnect moest.

Hoewel ik het wel raar vind, als ik GEEN "#if defined FILTERSCRIPT" bovenaan heb staan, geeft hij erg veel errors.

Wanneer ik dit er wel neer zet, krijg ik ALLEEN de volgende error:

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(336) : error 001: expected token: "#endif", but found "-end of file-"

Maar als ik dan #endif toevoeg, krijg ik weer de errors die in de topic staan :/

Hier zijn de errors als ik het ZONDER #if defined FILTERSCRIPT en #endif:

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(60) : warning 217: loose indentation

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(60) : error 021: symbol already defined: "n"

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(61) : warning 217: loose indentation

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(77) : warning 217: loose indentation

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(86) : warning 217: loose indentation

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(91) : warning 217: loose indentation

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(91) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(91) : error 004: function "OnPlayerSpawn" is not implemented

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(96) : warning 225: unreachable code

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(96) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(96) : error 004: function "OnPlayerDeath" is not implemented

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(101) : warning 225: unreachable code

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(101) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(101) : error 004: function "OnVehicleSpawn" is not implemented

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(106) : warning 225: unreachable code

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(106) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(106) : error 004: function "OnVehicleDeath" is not implemented

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(111) : warning 225: unreachable code

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(111) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(111) : error 004: function "OnPlayerText" is not implemented

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(116) : warning 225: unreachable code

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(116) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(116) : error 004: function "OnPlayerCommandText" is not implemented

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(117) : error 001: expected token: ";", but found "new"

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(117) : warning 217: loose indentation

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(118) : error 017: undefined symbol "strtok"

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(118) : error 033: array must be indexed (variable "cmd")

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(119) : error 017: undefined symbol "cmdtext"

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(119) : error 029: invalid expression, assumed zero

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(119) : warning 215: expression has no effect

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(119) : error 001: expected token: ";", but found "]"

C:\Users\fts\Desktop\SA-MP-03ccc\gamemodes\aaddmmiinn.pwn(119) : fatal error 107: too many error messages on one line

Geplaatst:

Ik kan het zelf echt niet vinden, maar als iemand zou kunnen kijken, zou ik dat waarderen, sorry dat ik zo gehaast ben hoor, maar morge ochtend ga ik op vkantie en dan als ik terug kom ben ik weer helemaal uit het scripten als je begrijpt wat ik bedoel :PPP

DE ERRORS STAAN 2 POSTS OMHOOG^^^^^^

EN HIER HET SCRIPT:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define GREY 0xAFAFAFAA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA

enum gPInfo
{
   Logged,
   Regged,
   Level
};
new PInfo[MAX_PLAYERS][gPInfo];

main()
{
   print("\n----------------------------------");
   print(" Blank Gamemode by your name here");
   print("----------------------------------\n");
}


public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
   SetGameModeText("Blank Script");
   AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
   return 1;
}


public OnGameModeExit()
{
   return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
   SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
   SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
   SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
   return 1;
}


public OnPlayerConnect(playerid)
{
   new file[256],n[MAX_PLAYER_NAME];
   GetPlayerName(playerid,n,MAX_PLAYER_NAME);
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
   PInfo[playerid][Logged] = 0;
   PInfo[playerid][Regged] = 0;
   PInfo[playerid][Level] = 0;
   new n[MAX_PLAYER_NAME], file[256];
   GetPlayerName(playerid,n,sizeof(n));
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
   if(dini_Exists(file)) {
       SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
       PInfo[playerid][Regged] = 1;
       PInfo[playerid][Logged] = 0;
       return 1;
   }
   if(!dini_Exists(file)) {
       SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
       PInfo[playerid][Regged] = 0;
       PInfo[playerid][Logged] = 0;
       return 1;
   }
   return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
   new n[MAX_PLAYER_NAME], file[256];
   GetPlayerName(playerid,n,sizeof(n));
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
   PInfo[playerid][Logged] = 0;
   if(dini_Exists(file)) {
       dini_IntSet(file,"Logged",0);
       return 1;
   }
   public OnPlayerSpawn(playerid) {
       return 1;
   }

   public OnPlayerDeath(playerid, killerid, reason) {
       return 1;
   }

   public OnVehicleSpawn(vehicleid) {
       return 1;
   }

   public OnVehicleDeath(vehicleid, killerid) {
       return 1;
   }

   public OnPlayerText(playerid, text[]) {
       return 1;
   }

   public OnPlayerCommandText(playerid, cmdtext[])
       new cmd[256], idx;
   cmd = strtok(cmdtext, idx);
   dcmd(register,8,cmdtext);
   dcmd(setlevel,8,cmdtext);
   dcmd(kick,4,cmdtext);
   dcmd(ban,3,cmdtext);
   return 0;
}


//register-
dcmd_register(playerid,params[])
{
   if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are already registered!");
   if(PInfo[playerid][Regged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
   if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
   if(strlen(params)) {
       if(!dini_Exists(file)) {
           dini_Create(file);
           dini_Set(file,"Password",params);
           dini_IntSet(file,"Regged",1);
           dini_IntSet(file,"Logged",0);
           dini_IntSet(file,"Level",0);
           SendClientMessage(playerid,LIGHTBLUE,"Congratulations, you have just registered, please /login");
           PInfo[playerid][Regged] = 1;
       }
       else {
           SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
           return 1;
       }
       dcmd_setlevel(playerid,params[]) {
                                                 //creating the new variabls
           new level,id,file[256],n[MAX_PLAYER_NAME];
                                                 // creating the new variables
           new tmp[256], tmp2[256], Index,str[50];
                                                 // setting them to strtok so we can use them as parameters of our command
           tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
           GetPlayerName(id,n,MAX_PLAYER_NAME);  //getting the players name
                                                 //formatting the file
           format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
                                                 //if the player is not rcon admin
           if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
                                                 // if the string is empty
           if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
                                                 //if the id is not connected
           if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
           PInfo[id][Level] = level;             //sets the level of the player
           dini_IntSet(file,"Level",level);      //saves the new level to the file
                                                 //creates the string
           format(str,sizeof(str),"You have set %s's level to %d",n,level);
           SendClientMessage(playerid,LIGHTBLUE,str);
           return 1;
       }
       dcmd_kick(playerid,params[]) {
           new id,n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
           new tmp[256], Index, str[49];
           tmp = strtok(params,Index), id = strval(tmp);
           GetPlayerName(id,on,sizeof(on));
           GetPlayerName(playerid,n,sizeof(n));
           if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
           if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /kick <ID> ");
           if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
           format(str,sizeof(str),"%s has kicked %s",n,on);
           SendClientMessageToAll(LIGHTBLUE,str);
           Kick(id);
           return 1;
       }
       dcmd_ban(playerid,params[]) {
           new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
           new tmp[256], Index, str[49];
           tmp = strtok(params,Index), id = strval(tmp);
           GetPlayerName(id,on,sizeof(on));
           GetPlayerName(playerid,n,sizeof(n));
           if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
           if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /ban <ID> ");
           if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
           format(str,sizeof(str),"%s has banned %s",n,on);
           SendClientMessageToAll(ORANGE,str);
           Ban(id);
           return 1;
       }
       return 1;
   }
}


return 0;
}


public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
   return 1;
}


public OnPlayerExitVehicle(playerid, vehicleid)
{
   return 1;
}


public OnPlayerStateChange(playerid, newstate, oldstate)
{
   return 1;
}


public OnPlayerEnterCheckpoint(playerid)
{
   return 1;
}


public OnPlayerLeaveCheckpoint(playerid)
{
   return 1;
}


public OnPlayerEnterRaceCheckpoint(playerid)
{
   return 1;
}


public OnPlayerLeaveRaceCheckpoint(playerid)
{
   return 1;
}


public OnRconCommand(cmd[])
{
   return 1;
}


public OnPlayerRequestSpawn(playerid)
{
   return 1;
}


public OnObjectMoved(objectid)
{
   return 1;
}


public OnPlayerObjectMoved(playerid, objectid)
{
   return 1;
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
   return 1;
}


public OnVehicleMod(playerid, vehicleid, componentid)
{
   return 1;
}


public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
   return 1;
}


public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
   return 1;
}


public OnPlayerSelectedMenuRow(playerid, row)
{
   return 1;
}


public OnPlayerExitedMenu(playerid)
{
   return 1;
}


public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
   return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   return 1;
}


public OnRconLoginAttempt(ip[], password[], success)
{
   return 1;
}


public OnPlayerUpdate(playerid)
{
   return 1;
}


public OnPlayerStreamIn(playerid, forplayerid)
{
   return 1;
}


public OnPlayerStreamOut(playerid, forplayerid)
{
   return 1;
}


public OnVehicleStreamIn(vehicleid, forplayerid)
{
   return 1;
}


public OnVehicleStreamOut(vehicleid, forplayerid)
{
   return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   return 1;
}


public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
   return 1;
}

Geplaatst: (bewerkt)

Tussen je commando's en OnPlayerEnterVehicle staat:

    return 0;
}

Als je dat weglaat zullen er al een hoop errors weg zijn.

EDIT: Goed, ik ben lang beziggeweest maar ik heb je identatie weer goed gezet, alle overbodige brackets (en dat waren er wel wat) verwijderd, brackets toegevoegd waar nodig. Je variabels wat geoptimaliseerd, een PlayerName functie gemaakt die vele efficiënter is dan altijd weer een variable aanmaken en hem erin stoppen. Het script kan nog vele efficiënter en beter worden als je zoals Big Boss al zei gebruikt maakt van zcmd en Y_INI. Ook raad ik je sscanf aan inplaats van strtok.

Je huidige code:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define GREY 0xAFAFAFAA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA

enum gPInfo
{
   Logged,
   Regged,
   Level
};
new PInfo[MAX_PLAYERS][gPInfo];

main()
{
   print("\n----------------------------------");
   print(" Blank Gamemode by your name here");
   print("----------------------------------\n");
}


public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
   SetGameModeText("Blank Script");
   AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
   return 1;
}


public OnGameModeExit()
{
   return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
   SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
   SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
   SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
   return 1;
}


public OnPlayerConnect(playerid)
{
   new file[70];
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   PInfo[playerid][Logged] = 0;
   PInfo[playerid][Regged] = 0;
   PInfo[playerid][Level] = 0;

   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   if(dini_Exists(file)) {
       SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
       PInfo[playerid][Regged] = 1;
       PInfo[playerid][Logged] = 0;
   }
else
{
       SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
       PInfo[playerid][Regged] = 0;
       PInfo[playerid][Logged] = 0;
   }
   return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
   new file[70];
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   PInfo[playerid][Logged] = 0;
   if(dini_Exists(file))
	dini_IntSet(file,"Logged",0);
return 1;
}

public OnPlayerSpawn(playerid) {
return 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
return 1;
}

public OnVehicleSpawn(vehicleid) {
return 1;
}

public OnVehicleDeath(vehicleid, killerid) {
return 1;
}

public OnPlayerText(playerid, text[]) {
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
dcmd(register,8,cmdtext);
dcmd(setlevel,8,cmdtext);
dcmd(kick,4,cmdtext);
dcmd(ban,3,cmdtext);
   return 0;
}


//register-
dcmd_register(playerid,params[])
{
new file[70];
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are already registered!");
   if(PInfo[playerid][Regged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
   if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
   if(strlen(params))
{
       if(!dini_Exists(file)) 
	{
           dini_Create(file);
           dini_Set(file,"Password",params);
           dini_IntSet(file,"Regged",1);
           dini_IntSet(file,"Logged",0);
           dini_IntSet(file,"Level",0);
           SendClientMessage(playerid,LIGHTBLUE,"Congratulations, you have just registered, please /login");
           PInfo[playerid][Regged] = 1;
       }
       else 
	{
           SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
	}
}
   return 1;
}

dcmd_setlevel(playerid,params[]) 
{
//creating the new variabls
new level,id,file[70];
                                                 // creating the new variables
   new tmp[128], tmp2[128], Index,str[50];
                                                 // setting them to strtok so we can use them as parameters of our command
   tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
                                                 //formatting the file
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
                                                 //if the player is not rcon admin
   if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
                                                 // if the string is empty
   if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
                                                 //if the id is not connected
   if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
   PInfo[id][Level] = level;             //sets the level of the player
   dini_IntSet(file,"Level",level);      //saves the new level to the file
                                                 //creates the string
   format(str,sizeof(str),"You have set %s's level to %d",PlayerName(playerid),level);
   SendClientMessage(playerid,LIGHTBLUE,str);
   return 1;
}

dcmd_kick(playerid,params[]) 
{
   new id;
   new tmp[128], Index, str[49];
   tmp = strtok(params,Index), id = strval(tmp);
   if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
   if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /kick <ID> ");
   if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
   format(str,sizeof(str),"%s has kicked %s",PlayerName(playerid),PlayerName(id));
   SendClientMessageToAll(LIGHTBLUE,str);
   Kick(id);
return 1;
}

dcmd_ban(playerid,params[]) 
{
new id;
   new tmp[128], Index, str[49];
   tmp = strtok(params,Index), id = strval(tmp);
   if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
   if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /ban <ID> ");
   if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
   format(str,sizeof(str),"%s has banned %s",PlayerName(playerid),PlayerName(id));
   SendClientMessageToAll(ORANGE,str);
   Ban(id);
   return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
   return 1;
}


public OnPlayerExitVehicle(playerid, vehicleid)
{
   return 1;
}


public OnPlayerStateChange(playerid, newstate, oldstate)
{
   return 1;
}


public OnPlayerEnterCheckpoint(playerid)
{
   return 1;
}


public OnPlayerLeaveCheckpoint(playerid)
{
   return 1;
}


public OnPlayerEnterRaceCheckpoint(playerid)
{
   return 1;
}


public OnPlayerLeaveRaceCheckpoint(playerid)
{
   return 1;
}


public OnRconCommand(cmd[])
{
   return 1;
}


public OnPlayerRequestSpawn(playerid)
{
   return 1;
}


public OnObjectMoved(objectid)
{
   return 1;
}


public OnPlayerObjectMoved(playerid, objectid)
{
   return 1;
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
   return 1;
}


public OnVehicleMod(playerid, vehicleid, componentid)
{
   return 1;
}


public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
   return 1;
}


public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
   return 1;
}


public OnPlayerSelectedMenuRow(playerid, row)
{
   return 1;
}


public OnPlayerExitedMenu(playerid)
{
   return 1;
}


public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
   return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   return 1;
}


public OnRconLoginAttempt(ip[], password[], success)
{
   return 1;
}


public OnPlayerUpdate(playerid)
{
   return 1;
}


public OnPlayerStreamIn(playerid, forplayerid)
{
   return 1;
}


public OnPlayerStreamOut(playerid, forplayerid)
{
   return 1;
}


public OnVehicleStreamIn(vehicleid, forplayerid)
{
   return 1;
}


public OnVehicleStreamOut(vehicleid, forplayerid)
{
   return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   return 1;
}


public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
   return 1;
}

stock PlayerName(playerid)
{
new PlrName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlrName, sizeof(PlrName));
return PlrName;
}

strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
	index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
	result[index - offset] = string[index];
	index++;
}
result[index - offset] = EOS;
return result;
}

NOTE: Het kan zijn dat de identatie niet goed lijkt in deze codebox maar hij is WEL goed als je hem in pawno of notepad++ kopieert.

Bewerkt: door Megadreams
Geplaatst:

Staan mijn instellingen van mijn PC niet goed ofzoo?? want als ik dit wil kopieren, paste hij in pawn alles op 1 line..

is er een manier om dit sneller te fixen :puh:

Geplaatst: (bewerkt)

Probeer nu nog eens (deze komt wel uit Pawno, de vorige was in Notepad++):

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define GREY 0xAFAFAFAA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA

enum gPInfo
{
   Logged,
   Regged,
   Level
};
new PInfo[MAX_PLAYERS][gPInfo];

main()
{
   print("\n----------------------------------");
   print(" Blank Gamemode by your name here");
   print("----------------------------------\n");
}


public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
   SetGameModeText("Blank Script");
   AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
   return 1;
}


public OnGameModeExit()
{
   return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
   SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
   SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
   SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
   return 1;
}


public OnPlayerConnect(playerid)
{
   new file[70];
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   PInfo[playerid][Logged] = 0;
   PInfo[playerid][Regged] = 0;
   PInfo[playerid][Level] = 0;

   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   if(dini_Exists(file)) {
       SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
       PInfo[playerid][Regged] = 1;
       PInfo[playerid][Logged] = 0;
   }
else
{
       SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
       PInfo[playerid][Regged] = 0;
       PInfo[playerid][Logged] = 0;
   }
   return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
   new file[70];
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   PInfo[playerid][Logged] = 0;
   if(dini_Exists(file))
	dini_IntSet(file,"Logged",0);
return 1;
}

public OnPlayerSpawn(playerid) {
return 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
return 1;
}

public OnVehicleSpawn(vehicleid) {
return 1;
}

public OnVehicleDeath(vehicleid, killerid) {
return 1;
}

public OnPlayerText(playerid, text[]) {
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
dcmd(register,8,cmdtext);
dcmd(setlevel,8,cmdtext);
dcmd(kick,4,cmdtext);
dcmd(ban,3,cmdtext);
   return 0;
}


//register-
dcmd_register(playerid,params[])
{
new file[70];
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
   if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are already registered!");
   if(PInfo[playerid][Regged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
   if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
   if(strlen(params))
{
       if(!dini_Exists(file))
	{
           dini_Create(file);
           dini_Set(file,"Password",params);
           dini_IntSet(file,"Regged",1);
           dini_IntSet(file,"Logged",0);
           dini_IntSet(file,"Level",0);
           SendClientMessage(playerid,LIGHTBLUE,"Congratulations, you have just registered, please /login");
           PInfo[playerid][Regged] = 1;
       }
       else
	{
           SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
	}
}
   return 1;
}

dcmd_setlevel(playerid,params[])
{
//creating the new variabls
new level,id,file[70];
                                                 // creating the new variables
   new tmp[128], tmp2[128], Index,str[50];
                                                 // setting them to strtok so we can use them as parameters of our command
   tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
                                                 //formatting the file
   format(file,sizeof(file),"MyAdmin/Users/%s.txt",PlayerName(playerid));
                                                 //if the player is not rcon admin
   if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
                                                 // if the string is empty
   if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
                                                 //if the id is not connected
   if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
   PInfo[id][Level] = level;             //sets the level of the player
   dini_IntSet(file,"Level",level);      //saves the new level to the file
                                                 //creates the string
   format(str,sizeof(str),"You have set %s's level to %d",PlayerName(playerid),level);
   SendClientMessage(playerid,LIGHTBLUE,str);
   return 1;
}

dcmd_kick(playerid,params[])
{
   new id;
   new tmp[128], Index, str[49];
   tmp = strtok(params,Index), id = strval(tmp);
   if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
   if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /kick <ID> ");
   if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
   format(str,sizeof(str),"%s has kicked %s",PlayerName(playerid),PlayerName(id));
   SendClientMessageToAll(LIGHTBLUE,str);
   Kick(id);
return 1;
}

dcmd_ban(playerid,params[])
{
new id;
   new tmp[128], Index, str[49];
   tmp = strtok(params,Index), id = strval(tmp);
   if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
   if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /ban <ID> ");
   if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
   format(str,sizeof(str),"%s has banned %s",PlayerName(playerid),PlayerName(id));
   SendClientMessageToAll(ORANGE,str);
   Ban(id);
   return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
   return 1;
}


public OnPlayerExitVehicle(playerid, vehicleid)
{
   return 1;
}


public OnPlayerStateChange(playerid, newstate, oldstate)
{
   return 1;
}


public OnPlayerEnterCheckpoint(playerid)
{
   return 1;
}


public OnPlayerLeaveCheckpoint(playerid)
{
   return 1;
}


public OnPlayerEnterRaceCheckpoint(playerid)
{
   return 1;
}


public OnPlayerLeaveRaceCheckpoint(playerid)
{
   return 1;
}


public OnRconCommand(cmd[])
{
   return 1;
}


public OnPlayerRequestSpawn(playerid)
{
   return 1;
}


public OnObjectMoved(objectid)
{
   return 1;
}


public OnPlayerObjectMoved(playerid, objectid)
{
   return 1;
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
   return 1;
}


public OnVehicleMod(playerid, vehicleid, componentid)
{
   return 1;
}


public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
   return 1;
}


public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
   return 1;
}


public OnPlayerSelectedMenuRow(playerid, row)
{
   return 1;
}


public OnPlayerExitedMenu(playerid)
{
   return 1;
}


public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
   return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   return 1;
}


public OnRconLoginAttempt(ip[], password[], success)
{
   return 1;
}


public OnPlayerUpdate(playerid)
{
   return 1;
}


public OnPlayerStreamIn(playerid, forplayerid)
{
   return 1;
}


public OnPlayerStreamOut(playerid, forplayerid)
{
   return 1;
}


public OnVehicleStreamIn(vehicleid, forplayerid)
{
   return 1;
}


public OnVehicleStreamOut(vehicleid, forplayerid)
{
   return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   return 1;
}


public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
   return 1;
}

stock PlayerName(playerid)
{
new PlrName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlrName, sizeof(PlrName));
return PlrName;
}

strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
	index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
	result[index - offset] = string[index];
	index++;
}
result[index - offset] = EOS;
return result;
}

Bewerkt: door Megadreams
Geplaatst:

Waarom komt hij met een compleet script met dcmd en alles. en is zijn fout een paar haakjes of whatever?

Je kan beter beginnen met de tutorial van sandra?. dan leer je over hoe het moet. je moet niet gelijk in gevorderd scripten inspringen. maak je het jezelf alleen maar moeilijker mee

je moet beginnen met simpele dingen?. knippen en plakken van overal en nog wat krijg je alleen maar onstabiele ram vretende servers van...

Een reactie plaatsen

Je kan nu een reactie plaatsen en pas achteraf registreren. Als je al lid bent, log eerst in om met je eigen account een reactie te plaatsen.

Gast
Op dit onderwerp reageren...

×   Je hebt text geplaatst met opmaak.   Opmaak verwijderen

  Only 75 emoji are allowed.

×   Je link is automatisch ingevoegd.   In plaats daarvan weergeven als link

×   Je vorige bewerkingen zijn hersteld.   Alles verwijderen

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent actief   0 leden

    • Er zijn hier geen geregistreerde gebruikers aanwezig.
×
×
  • Create New...