PDA

View Full Version : [HELP]Anti Spawnkill problem


qazwsx
27/07/2013, 11:20 AM
Hi guys, ive made some Script For Anti Spawnkill protection.
Here is the code :

public OnPlayerRequestClass(playerid)
{
SetPlayerHealth(playerid, 1000000);
SetTimerEx("endspawnkillprotect", 5000, false, "i", playerid);
SendClientMessage(playerid, COLOR_BRIGHTRED, "Youre Protected by Anti Spawnkill Now");
return 1;
}

And here is the endspawnkillprotect
public endspawnkillprotect(playerid)
{
SetPlayerHealth(playerid, 100.0);
SetPlayerArmor(playerid, 100.);
}

Here is the error code when i compiled it:
E:\Rockstar Games\GTA San Andreas\samp03x_svr_R1-2_win32_3\gamemodes\owntdm.pwn(116) : warning 217: loose indentation
E:\Rockstar Games\GTA San Andreas\samp03x_svr_R1-2_win32_3\gamemodes\owntdm.pwn(117) : warning 217: loose indentation
E:\Rockstar Games\GTA San Andreas\samp03x_svr_R1-2_win32_3\gamemodes\owntdm.pwn(175) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

ScRipTeRi
27/07/2013, 11:33 AM
public OnPlayerRequestClass(playerid)
{
SetPlayerHealth(playerid, 1000000);
SetTimerEx("endspawnkillprotect", 5000, false, "i", playerid);
SendClientMessage(playerid, COLOR_BRIGHTRED, "Youre Protected by Anti Spawnkill Now");
return 1;
}
public endspawnkillprotect(playerid)
{
SetPlayerHealth(playerid, 100.0);
SetPlayerArmor(playerid, 100.0);
return 1;
}

qazwsx
27/07/2013, 11:39 AM
public OnPlayerRequestClass(playerid)
{
SetPlayerHealth(playerid, 1000000);
SetTimerEx("endspawnkillprotect", 5000, false, "i", playerid);
SendClientMessage(playerid, COLOR_BRIGHTRED, "Youre Protected by Anti Spawnkill Now");
return 1;
}
public endspawnkillprotect(playerid)
{
SetPlayerHealth(playerid, 100.0);
SetPlayerArmor(playerid, 100.0);
return 1;
}

Whats the different? -_-
What you wrote, is what have i wrote in my gamemode lol.

ScRipTeRi
27/07/2013, 11:44 AM
SetPlayerArmor(playerid, 100.); this was your and SetPlayerArmor(playerid, 100.0); min this was diferent

qazwsx
27/07/2013, 11:47 AM
I changed the script like yours but it is still show me the same error :?

MellowHammer
27/07/2013, 11:48 AM
Make sure you have this line in your script:

forward endspawnkillprotect(playerid);

ScRipTeRi
27/07/2013, 11:51 AM
forward SpawnProtection(playerid);
public OnPlayerSpawn(playerid)
{
//Protected
SetTimerEx("SpawnProtection",5000,0,"i",playerid);
SetPlayerHealth(playerid,99999);
return 1;
}
public SpawnProtection(playerid)
{
SetPlayerHealth(playerid,100.0);
SetPlayerArmour(playerid,100.0);
return 1;
}

qazwsx
27/07/2013, 12:44 PM
Make sure you have this line in your script:

forward endspawnkillprotect(playerid);


Thanks mane :D
Lol, ive write that forward endspawnkillprotect(); without playerid :D

qazwsx
27/07/2013, 12:55 PM
And guys, the problem is how can i stop my timmer? :?
The function is contionously running, and how i can stop it? :?
please give me the code

ScRipTeRi
27/07/2013, 12:56 PM
killertime(timerid)

Donvalley
27/07/2013, 12:58 PM
taken from here:

http://wiki.sa-mp.com/wiki/SetTimerEx


// The event callback (OnPlayerSpawn) - we will start a timer here
public OnPlayerSpawn(playerid)
{
// Anti-Spawnkill (5 seconds)

// Set their health very high so they can't be killed
SetPlayerHealth(playerid, 999999);

// Notify them
SendClientMessage(playerid, -1, "You are protected against spawn-killing for 5 seconds.");

// Start a 5 second timer to end the anti-spawnkill
SetTimerEx("EndAntiSpawnKill", 5000, false, "i", playerid);
}

// Forward (make public) the function so the server can 'see' it
forward EndAntiSpawnKill(playerid);

// The timer function - the code to be executed when the timer is called goes here
public EndAntiSpawnKill(playerid)
{
// 5 seconds has passed, so let's set their health back to 100
SetPlayerHealth(playerid, 100);

// Let's notify them also
SendClientMessage(playerid, -1, "You are no longer protected against spawn-killing.");
return 1;
}

qazwsx
27/07/2013, 01:15 PM
How? :s
I have make it, but how? :s
Please give me the example :s