View Single Post
nergal
Veteran Member
Join Date: Apr 2012
Old 11-07-2020 , 18:16   Re: SourceGo: Experimental Golang to SourcePawn Transpiler
Reply With Quote #7

alright, with version v0.25a.
Here's a sample of a plugin that modifies the mantreads damage written in "SourceGolang" and the code it generated:

Code:
package main

import (
	"sdkhooks"
)

func main() {
	for i := 1; i<=MaxClients; i++ {
		if IsClientInGame(i) {
			OnClientPutInServer(i)
		}
	}
}


func OnClientPutInServer(client Entity) {
	SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage)
}

func OnTakeDamage(victim Entity, attacker, inflictor, damagetype, weapon *Entity, damage *float, damageForce, damagePos *Vec3) Action {
	if IsValidEntity(*weapon) && GetEntProp(*weapon, Prop_Send, "m_iItemDefinitionIndex")==444 {
		*damage *= 5.0
		return Plugin_Changed
	}
	return Plugin_Continue
}
Code:
/**
 * file generated by the GoToSourcePawn Transpiler v0.25a
 * Copyright 2020 (C) Kevin Yonan aka Nergal, Assyrianic.
 * GoToSourcePawn Project is licensed under MIT.
 * link: 'https://github.com/assyrianic/Go2SourcePawn'
 */

#include <sourcemod>
#include <sdkhooks>


public void OnPluginStart() {
	for (int i = 1; i <= MaxClients; i++) {
		if (IsClientInGame(i)) {
			OnClientPutInServer(i);
		}

	}

}

public void OnClientPutInServer(int client) {
	SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTakeDamage(int victim, int& attacker, int& inflictor, int& damagetype, int& weapon, float& damage, float damageForce[3], float damagePos[3]) {
	if (IsValidEntity(weapon) && GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex") == 444) {
		damage *= 5.0;
		return Plugin_Changed;
	}
	return Plugin_Continue;
}
__________________
nergal is offline