我正在尝试使用RAGE Plugin Hook,IronPython和C#为GTA V创建一个mod。不幸的是,我遇到了问题。
我收到一个例外,在C#或汇编中,而python是我的母语,我拿了;
[8/10/2016 7:39:14 AM.609] ------------------------------
[8/10/2016 7:39:14 AM.609] Exception type: System.ArgumentNullException
[8/10/2016 7:39:14 AM.609] Exception message: Value cannot be null.
[8/10/2016 7:39:14 AM.610] ------------------------------
[8/10/2016 7:39:14 AM.610] Inner exceptions:
[8/10/2016 7:39:14 AM.611] ------------------------------
[8/10/2016 7:39:14 AM.611] Stack trace:
[8/10/2016 7:39:14 AM.611] at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
[8/10/2016 7:39:14 AM.612] at Rage.Plugin.RemoteLogPluginCrash(Plugin plugin, Exception exception)
[8/10/2016 7:39:14 AM.612] at Rage.HookManager.LogPluginCrash(Plugin plugin, Exception exception)
[8/10/2016 7:39:14 AM.612] at Rage.GameFiber.Main()
[8/10/2016 7:39:14 AM.613] at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
[8/10/2016 7:39:14 AM.613] at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
[8/10/2016 7:39:14 AM.617] at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
[8/10/2016 7:39:14 AM.618] at System.Threading.ThreadHelper.ThreadStart()
[8/10/2016 7:39:14 AM.618] ==============================
意思是我忘了定义一个变量,引用一个不存在的变量,或者忘了为一个函数提供一个参数。
当然,我仔细查看并发现没有任何问题,所以我把它放在一个专门用于python的IDE中。
事实证明,我忘了提供论据,并且使用不当hasattr
。我及时解决了这些问题,然而问题仍然存在。
我正试图感受"对于C#仍然如此,所以我不确定这个错误引用了什么,因为它本来可以修复,或者本来应该是,并且python是我的母语。
我可能会将Rage.
部分称为错误,但这是我能找到的唯一问题。
启动脚本;
import clr
import Services
clr.AddReference('RagePluginHookSDK')
from RagePluginHookSDK import Rage
def Init():
wc = Rage.World()
gc = Rage.Game()
vl = []
return wc, gc, vl
def MainLoop(worldclass, gameclass, vehiclelist):
try:
Services.RefreshWorld()
Services.SetWeather(worldclass)
return True
except Exception, e:
Services.Notify("An error has occured: {0}; exiting...".format(e))
return False
wc, gc, vl = Init()
while True:
if not MainLoop(wc, gc, vl):
break
else:
Rage.GameFiber.Yield()
二手服务代码;
import clr
import random
import os
from math import pi
clr.AddReference('RagePluginHookSDK')
from RagePluginHookSDK import *
def GetMaxPeds(worldvar):
return worldvar.PedCapacity()
def RefreshWorld(worldvar):
pl = worldvar.GetAllPeds()
vl = worldvar.GetAllVehicles()
for item in pl:
if not hasattr(item, 'IsMine'):
item.Delete()
for item in vl:
if not hasattr(item, 'IsMine'):
item.Delete()
def Notify(gamevar, message):
Rage.Game.DisplayMessage(str(message))
def SetWeather(worldvar, to=None):
wtrv = random.randint(0,5)
if to != None:
ttl = 60
wt = to
elif wtrv == 0:
wt = 0
ttl = 90
elif wtrv == 1:
wt = 7
ttl = 45
elif wtrv == 2:
wt = 2
ttl = 30
elif wtrv == 3:
wt = 4
ttl = 45
elif wtrv == 4:
wt = 9
ttl = 15
worldvar.Weather.set(wt)
return ttl
def ReadVehicleData():
cwd = os.getcwd()
return []
错误跟踪太长而无法插入,我很抱歉!