#1

Hello well i just used a timer and i came across a bug that i havent before, I put "freeze" as one of my functions and it says it doesn't exist if there is a samp wiki page listing all the functions they have that would be appreciated, Here is the script i was working on:

Код:
forward freeze();

public OnPlayerCommandText(playerid,cmdtext[])

{
	if(!strcmp(cmdtext, "/kill", true))
	{
    new Float:x, Float:y, Float:z;
	SetPlayerHealth(playerid, 0);
	GetPlayerPos(playerid, x, y, z);
    return 1;
	}
	if(!strcmp(cmdtext, "/shop", true))
	{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop", "Weapons\nArmor\nDrugs(V.I.P)", "Select", "Cancel");
    return 1;
	}
	if (!strcmp("/enter", cmdtext))
{
    if (IsPlayerInRangeOfPoint(playerid, 7.0, 9634.5996, 5616.8052, 4.7742 ))
    {
    	SetPlayerPos(playerid, 2233.8032, 1712.2303, 1011.7632);
    {
 TogglePlayerControllable(playerid, 0);
 SetTimer("freeze", 1000, false);
}

public freeze()
		{
	TogglePlayerControllable(playerid, 1);
}

    }

    return 1;

}
As you can see i am making a script were once you enter a interior you get frozen for some time to avoid falling then you get unfrozen in about 1000 milliseconds (According to my timer.)

Here is the opcode i receive:

Код:
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(338) : warning 217: loose indentation
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(343) : warning 217: loose indentation
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(343) : error 029: invalid expression, assumed zero
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(343) : error 004: function "freeze" is not implemented
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(344) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
In my server.cfg file it says there is no gamemode.
Reply
#2

Also i do not want it to set your X position higher than the surface (so once you enter you fall to the ground)
Reply
#3

Read the errors, loose indentation, check your brackets again and I'm sure you'll find one missing because you don't script clean and organized.
Reply
#4

Код:
forward freeze();

public OnPlayerCommandText(playerid,cmdtext[])
{
	if(!strcmp(cmdtext, "/kill", true))
	{
		new Float:x, Float:y, Float:z;
		SetPlayerHealth(playerid, 0);
		GetPlayerPos(playerid, x, y, z);
 		return 1;
	}
	if(!strcmp(cmdtext, "/shop", true))
	{
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop", "Weapons\nArmor\nDrugs(V.I.P)", "Select", "Cancel");
  		return 1;
	}
	if (!strcmp("/enter", cmdtext))
	{
		if (IsPlayerInRangeOfPoint(playerid, 7.0, 9634.5996, 5616.8052, 4.7742 ))
  		{
	    	SetPlayerPos(playerid, 2233.8032, 1712.2303, 1011.7632);
		}
	 	TogglePlayerControllable(playerid, 0);
		SetTimer("freeze", 1000, false);
	}
	return 1;
}

public freeze()
{
	TogglePlayerControllable(playerid, 1);
	return 1;
}
listen to PrO.GameR
Reply
#5

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Read the errors, loose indentation, check your brackets again and I'm sure you'll find one missing because you don't script clean and organized.
Quote:
Originally Posted by Sascha
Посмотреть сообщение
Код:
forward freeze();

public OnPlayerCommandText(playerid,cmdtext[])
{
	if(!strcmp(cmdtext, "/kill", true))
	{
		new Float:x, Float:y, Float:z;
		SetPlayerHealth(playerid, 0);
		GetPlayerPos(playerid, x, y, z);
 		return 1;
	}
	if(!strcmp(cmdtext, "/shop", true))
	{
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop", "Weapons\nArmor\nDrugs(V.I.P)", "Select", "Cancel");
  		return 1;
	}
	if (!strcmp("/enter", cmdtext))
	{
		if (IsPlayerInRangeOfPoint(playerid, 7.0, 9634.5996, 5616.8052, 4.7742 ))
  		{
	    	SetPlayerPos(playerid, 2233.8032, 1712.2303, 1011.7632);
		}
	 	TogglePlayerControllable(playerid, 0);
		SetTimer("freeze", 1000, false);
	}
	return 1;
}

public freeze()
{
	TogglePlayerControllable(playerid, 1);
	return 1;
}
listen to PrO.GameR
Did what you guys said, Although it just made everything an invalid function:

Код:
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(347) : error 017: undefined symbol "playerid"
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(350) : error 010: invalid function or declaration
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(352) : error 010: invalid function or declaration
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(357) : error 010: invalid function or declaration
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(359) : error 010: invalid function or declaration
Reply
#6

PHP код:
public freeze(playerid//you forgot "playerid"
{
    
TogglePlayerControllable(playerid1);
    return 
1;

Reply
#7

It's dragging the errors to another line which i am 100% sure has no bugs


Opcode:

Код:
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(345) : error 025: function heading differs from prototype
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(350) : error 010: invalid function or declaration
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(352) : error 010: invalid function or declaration
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(357) : error 010: invalid function or declaration
C:\Users\User\Desktop\LSRP\gamemodes\new.pwn(359) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Script lines:

Код:
public freeze(playerid)
{
	TogglePlayerControllable(playerid, 1);
	return 1;
}
    if(!strcmp(cmdtext, "/crackdoor", true))
	{
		if IsPlayerInRangeOfPoint(playerid, 3.0, 2143.1616, 1627.3285, 994.2775 ))
		{
    	MoveObject(19799, 0, 0, 179.1810-47.5975, 0.0001, 0.0, 0.0, 131.5835);
    	ApplyAnimation(playerid, "INT_HOUSE", "wash_up", 4.1, 1, 0, 0, 0, 3000, 1);
    	}
    	return 1;
}
    return 0;
Reply
#8

first, you need to change the
Код:
forward freeze();
from before to
Код:
forward freeze(playerid);
Then you need to learn general scripting structure...
You have to put the
Код:
if(!strcmp(cmdtext, "/crackdoor", true))
	{
		if IsPlayerInRangeOfPoint(playerid, 3.0, 2143.1616, 1627.3285, 994.2775 ))
		{
    	MoveObject(19799, 0, 0, 179.1810-47.5975, 0.0001, 0.0, 0.0, 131.5835);
    	ApplyAnimation(playerid, "INT_HOUSE", "wash_up", 4.1, 1, 0, 0, 0, 3000, 1);
    	}
    	return 1;
}
into
Код:
public OnPlayerCommandText(playerid, cmdtext[])
You can't just put any line anywhere in the script and add publics into other publics...

learn the basics, maybe this will help:
https://sampwiki.blast.hk/wiki/Scripting_Basics
https://sampwiki.blast.hk/wiki/Category:Scripting_Functions
https://sampwiki.blast.hk/wiki/Category:Scripting_Callbacks
https://sampwiki.blast.hk/wiki/Category:Tutorials
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)