View Single Post
Author Message
Tank_in_Pink
Member
Join Date: Feb 2016
Old 03-12-2018 , 17:58   What am I doing wrong?
Reply With Quote #1

Hey guys,

I'm currently writing my first plugin in SourcePawn. I understand the basics of programming but have no idea of SourcePawn.
I think there are just some minor issues but the plugin should work if they are fixed.
I couldn't really figure out how the timer works so there might be some problems with it.
I also can't figure out what to put as parameters inside the brackets of "Event_PlayerDeath" and "PrintMessage".

This is my code:
Code:
#include <sourcemod>

public Plugin:myinfo = 
{
	name = "...",
	author = "...",
	description = "...",
	version = "1.0",
	url = "..."
}

public OnPluginStart()
{
	HookEvent("player_death", Event_PlayerDeath);
	static int countdownTimer = 30;
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
	CreateTimer(1.0, PrintMessage, _, TIMER_REPEAT);
	countdownTimer = 30;
}

public Action PrintMessage(Handle timer)
{
	if (countdownTimer > 0) 
	{
		new client = GetClientOfUserId(GetEventInt(event, "userid"));
		PrintCenterText(client, "You are dead. You will be respawned at a random location in" + countdownTimer + "seconds.")
	
		countdownTimer--;
	}
 
	return Plugin_Continue;
}
Some help and explenation would be awesome :3

Thanks already,
hazetank

Last edited by Tank_in_Pink; 03-12-2018 at 17:59.
Tank_in_Pink is offline