SA-MP Forums Archive
What i am doing wrong here? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What i am doing wrong here? (/showthread.php?tid=562728)



What i am doing wrong here? - Nabster - 11.02.2015

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>


new JailTimer[MAX_PLAYERS];
new Jailed[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
   CMD:jail(playerid,params[]){
   if(IsPlayerAdmin(playerid))
   new id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME];
   if(sscanf(params,"dds",id,time,reason)) return SendClientMessage(playerid, lb, "USAGE: /jail <playerid> <time> <reason>");
   if (!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "ERROR: Player is not connected.");
   if(Jailed[id] == 1) return SendClientMessage(playerid, red, "ERROR: Player is already jailed.");
   GetPlayerName(id, PlayerName, sizeof(PlayerName));
   GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
   format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason);
   SendClientMessageToAll(color, szString);
   SetPlayerInterior(id, 3);
		SetPlayerVirtualWorld(id, 10);
		SetPlayerFacingAngle(id, 360.0);
		SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
		SetPlayerHealth(id, 9999999999.0);
		ResetPlayerWeapons(id);
		JailTimer[id] = SetTimerEx("Unjail",time*60000, false, "i", id);
	}
	else {
	    return 0;
	}
	return 1;
}
Its from a tutorial i am learning,i get these errors

C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 11) : error 029: invalid expression, assumed zero
C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 11) : error 017: undefined symbol "cmd_jail"
C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 11) : error 029: invalid expression, assumed zero
C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 11) : fatal error 107: too many error messages on one line


Re: What i am doing wrong here? - ATGOggy - 11.02.2015

Try using the define of zcmd


Re: What i am doing wrong here? - Luis- - 11.02.2015

You don't use ZCMD like that. Don't put your commands in OnPlayerCommandText, just put them at the bottom of your script after all the publics.


Re: What i am doing wrong here? - caoraivoso3 - 11.02.2015

you dont put a functions inside a callback, the cmd is a function you should put it outside.


Re: What i am doing wrong here? - Nabster - 11.02.2015

Now i am getting these errors

C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 33) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 33) : error 017: undefined symbol "id"
C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 33) : warning 215: expression has no effect
C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 33) : error 001: expected token: ";", but found "]"
C:\Users\Trayansh\Desktop\SAMP\gamemodes\jail.pwn( 33) : fatal error 107: too many error messages on one line


Re: What i am doing wrong here? - Luis- - 11.02.2015

Should work;
pawn Код:
CMD:jail(playerid,params[]){
    if(IsPlayerAdmin(playerid)) {
        new id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME];
        if(sscanf(params,"dds",id,time,reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /jail <playerid> <time> <reason>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: Player is not connected.");
        if(Jailed[id] == 1) return SendClientMessage(playerid, red, "ERROR: Player is already jailed.");
        GetPlayerName(id, PlayerName, sizeof(PlayerName));
        GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
        format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason);
        SendClientMessageToAll(0xFFFFFFFF, szString);
        SetPlayerInterior(id, 3);
        SetPlayerVirtualWorld(id, 10);
        SetPlayerFacingAngle(id, 360.0);
        SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
        SetPlayerHealth(id, 9999999999.0);
        ResetPlayerWeapons(id);
        JailTimer[id] = SetTimerEx("Unjail",time*60000, false, "i", id);
    }
    else {
        SendClientMessage(playerid, 0xFFFFFFFF, "You're not an admin.");
    }
    return 1;
}



Re: What i am doing wrong here? - Nabster - 11.02.2015

error 017: undefined symbol "szString"


Re: What i am doing wrong here? - Luis- - 11.02.2015

You just need to add "new szString[128+MAX_PLAYER_NAME]" to the variable list;
pawn Код:
CMD:jail(playerid,params[]){
    if(IsPlayerAdmin(playerid)) {
        new id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME], szString[128+MAX_PLAYER_NAME];
        if(sscanf(params,"dds",id,time,reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /jail <playerid> <time> <reason>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: Player is not connected.");
        if(Jailed[id] == 1) return SendClientMessage(playerid, red, "ERROR: Player is already jailed.");
        GetPlayerName(id, PlayerName, sizeof(PlayerName));
        GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
        format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason);
        SendClientMessageToAll(0xFFFFFFFF, szString);
        SetPlayerInterior(id, 3);
        SetPlayerVirtualWorld(id, 10);
        SetPlayerFacingAngle(id, 360.0);
        SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
        SetPlayerHealth(id, 9999999999.0);
        ResetPlayerWeapons(id);
        JailTimer[id] = SetTimerEx("Unjail",time*60000, false, "i", id);
    }
    else {
        SendClientMessage(playerid, 0xFFFFFFFF, "You're not an admin.");
    }
    return 1;
}



Re: What i am doing wrong here? - Nabster - 11.02.2015

Wew,thank you very much.
I wish i can rep you but idk why i can't and can you tell me what was wrong with my old code and what did you fix?

Once again ty


Re: What i am doing wrong here? - Luis- - 11.02.2015

Sure I can!

Basically, the function OnPlayerCommandText isn't used for ZCMD as ZCMD commands are used as functions also on your original code, the "IsPlayerAdmin" was missing a bracket so it couldn't go any further reading the code cause it'd stop compiling where the missing bracket was.